feat: add button to sign out to all connected devices
This commit is contained in:
parent
c4bb7c9b17
commit
38e227a9d4
@ -170,13 +170,13 @@ export const UserSettings: React.FC = () => {
|
||||
}
|
||||
|
||||
const handleSignout = async (): Promise<void> => {
|
||||
try {
|
||||
setFetchState('loading')
|
||||
await authentication.signoutServerSide()
|
||||
} catch (error) {
|
||||
setFetchState('error')
|
||||
setMessage('errors:server-error')
|
||||
}
|
||||
|
||||
const handleSignoutAllDevices = async (): Promise<void> => {
|
||||
setFetchState('loading')
|
||||
await authentication.signoutAllDevicesServerSide()
|
||||
}
|
||||
|
||||
const handleDeletionProvider = (
|
||||
@ -375,6 +375,11 @@ export const UserSettings: React.FC = () => {
|
||||
{t('application:signout')}
|
||||
</Button>
|
||||
</div>
|
||||
<div className='mt-4'>
|
||||
<Button type='button' color='red' onClick={handleSignoutAllDevices}>
|
||||
{t('application:signout-all-devices')}
|
||||
</Button>
|
||||
</div>
|
||||
<FormState
|
||||
state={fetchState}
|
||||
message={message != null ? t(message) : undefined}
|
||||
|
@ -25,6 +25,7 @@
|
||||
"success-email-changed": "Please check your emails to confirm your new email address. You are now signed out.",
|
||||
"delete": "Delete",
|
||||
"signout": "Sign out",
|
||||
"signout-all-devices": "Sign out of all devices",
|
||||
"signin-with-an-account": "Sign in with an account",
|
||||
"signout-with-an-account": "Sign out with an account",
|
||||
"success-deleted-provider": "The provider has been deleted.",
|
||||
|
@ -25,6 +25,7 @@
|
||||
"success-email-changed": "Veuillez vérifier vos emails pour confirmer votre nouvelle adresse email. Vous êtes maintenant déconnecté.",
|
||||
"delete": "Supprimer",
|
||||
"signout": "Se déconnecter",
|
||||
"signout-all-devices": "Se déconnecter de tous les appareils",
|
||||
"signin-with-an-account": "Se connecter avec un compte",
|
||||
"signout-with-an-account": "Se déconnecter avec un compte",
|
||||
"success-deleted-provider": "Le moyen de connexion a été supprimé.",
|
||||
|
@ -112,6 +112,13 @@ export class Authentication {
|
||||
this.signout()
|
||||
}
|
||||
|
||||
public async signoutAllDevicesServerSide(): Promise<void> {
|
||||
try {
|
||||
await this.api.delete('/users/signout')
|
||||
} catch {}
|
||||
this.signout()
|
||||
}
|
||||
|
||||
public signin(): void {
|
||||
cookies.set('refreshToken', this.tokens.refreshToken)
|
||||
}
|
||||
|
Reference in New Issue
Block a user