Skip to content

Commit

Permalink
Clean LastToken when relogin (#5303)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
  • Loading branch information
BykhovDenis authored Apr 12, 2024
1 parent fb40b9b commit ce7fc92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions plugins/login-resources/src/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { goTo } from './utils'
import login from './plugin'
import { type BottomAction } from '.'
import { setMetadataLocalStorage } from '@hcengineering/ui'
import { setMetadata } from '@hcengineering/platform'
import presentation from '@hcengineering/presentation'

export const signUpAction: BottomAction = {
caption: login.string.DoNotHaveAnAccount,
Expand All @@ -16,6 +19,8 @@ export const loginAction: BottomAction = {
i18n: login.string.LogIn,
page: 'login',
func: () => {
setMetadata(presentation.metadata.Token, null)
setMetadataLocalStorage(login.metadata.LastToken, null)
goTo('login', true)
}
}
Expand Down
12 changes: 11 additions & 1 deletion plugins/login-resources/src/components/SelectWorkspace.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
flagToUpdateWorkspaces = true
await updateWorkspaces()
} catch (err: any) {
setMetadataLocalStorage(login.metadata.LastToken, null)
setMetadataLocalStorage(presentation.metadata.Token, null)
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
setMetadataLocalStorage(login.metadata.LoginEmail, null)
Expand Down Expand Up @@ -160,7 +161,16 @@
{/if}
<div>
<span><Label label={login.string.NotSeeingWorkspace} /></span>
<NavLink href={getHref('login')}><Label label={login.string.ChangeAccount} /></NavLink>
<NavLink
href={getHref('login')}
onClick={() => {
setMetadataLocalStorage(login.metadata.LastToken, null)
setMetadataLocalStorage(presentation.metadata.Token, null)
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
setMetadataLocalStorage(login.metadata.LoginEmail, null)
goTo('login')
}}><Label label={login.string.ChangeAccount} /></NavLink
>
</div>
</div>
{/await}
Expand Down

0 comments on commit ce7fc92

Please sign in to comment.