Skip to content

Commit

Permalink
reload the page
Browse files Browse the repository at this point in the history
  • Loading branch information
kldavis4 committed Nov 8, 2023
1 parent 49798cf commit 3e78100
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions packages/tinacms-authjs/src/tinacms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ export const TINA_CREDENTIALS_PROVIDER_NAME = 'TinaCredentials'
export class DefaultAuthJSProvider extends AbstractAuthProvider {
readonly callbackUrl: string
readonly name: string
constructor(props?: { name?: string; callbackUrl?: string }) {
readonly redirect: boolean
constructor(props?: {
name?: string
callbackUrl?: string
redirect?: boolean
}) {
super()
this.name = props?.name || TINA_CREDENTIALS_PROVIDER_NAME
this.callbackUrl = props?.callbackUrl || '/admin/index.html'
this.redirect = props?.redirect ?? false
console.log('DefaultAuthJSProvider', this.name, this.callbackUrl)
}
async authenticate(props?: {}): Promise<any> {
Expand All @@ -34,7 +40,7 @@ export class DefaultAuthJSProvider extends AbstractAuthProvider {
}
logout() {
console.log('DefaultAuthJSProvider.logout', this.callbackUrl)
return signOut({ redirect: false, callbackUrl: this.callbackUrl })
return signOut({ redirect: this.redirect, callbackUrl: this.callbackUrl })
}
async authorize(context?: any): Promise<any> {
const user: any = (await getSession(context))?.user || {}
Expand Down
6 changes: 1 addition & 5 deletions packages/tinacms/src/auth/TinaCloudProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,7 @@ export const AuthWallInner = ({
if (typeof client?.onLogout === 'function') {
await client.onLogout()
}
const token = await authProvider.authenticate()
if (typeof client?.onLogin === 'function') {
await client?.onLogin({ token })
}
return onAuthenticated()
window.location.href = new URL(window.location.href).pathname
} catch (e) {
console.error(e)
setActiveModal('error')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function UpdatePassword(props: {}) {
// sleep for 1 second to allow the user to see the success message
await new Promise((resolve) => setTimeout(resolve, 1000))
client?.authProvider?.logout().catch((e) => console.error(e))
window.location.href = new URL(window.location.href).pathname
}
setFormState('idle')
}
Expand Down
3 changes: 3 additions & 0 deletions packages/tinacms/src/toolkit/react-sidebar/components/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export const Nav = ({
if (cms?.api?.tina?.onLogout) {
await cms?.api?.tina?.onLogout()
}
window.location.href = new URL(
window.location.href
).pathname
}
setEdit(false)
} catch (e) {
Expand Down

0 comments on commit 3e78100

Please sign in to comment.