feat: add button to sign out to all connected devices

This commit is contained in:
Divlo 2022-08-29 20:15:47 +02:00
parent c4bb7c9b17
commit 38e227a9d4
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
4 changed files with 21 additions and 7 deletions

View File

@ -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}

View File

@ -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.",

View File

@ -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é.",

View File

@ -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)
}