From 69193e9a463da3a227c155193bfc6b8af537cc3e Mon Sep 17 00:00:00 2001 From: Paul <paulmakles@gmail.com> Date: Thu, 8 Jul 2021 14:29:21 +0100 Subject: [PATCH] Add logic to "log out of all others". Consider tablet as desktop device. --- src/lib/isTouchscreenDevice.ts | 2 +- src/pages/settings/panes/Sessions.tsx | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/lib/isTouchscreenDevice.ts b/src/lib/isTouchscreenDevice.ts index ee67499..f1cd233 100644 --- a/src/lib/isTouchscreenDevice.ts +++ b/src/lib/isTouchscreenDevice.ts @@ -1,7 +1,7 @@ import { isDesktop, isMobile, isTablet } from "react-device-detect"; export const isTouchscreenDevice = - isDesktop && !isTablet + (isDesktop || isTablet) ? false : (typeof window !== "undefined" ? navigator.maxTouchPoints > 0 diff --git a/src/pages/settings/panes/Sessions.tsx b/src/pages/settings/panes/Sessions.tsx index c2b1f16..2a67c33 100644 --- a/src/pages/settings/panes/Sessions.tsx +++ b/src/pages/settings/panes/Sessions.tsx @@ -182,7 +182,27 @@ export function Sessions() { </div> ) })} - <Button error> + <Button error + onClick={async () => { + // ! FIXME: add to rAuth + let del: string[] = []; + render.forEach((session) => { + if (deviceId !== session.id) { + del.push(session.id); + } + }) + + setDelete(del); + + for (let id of del) { + await client.req( + "DELETE", + `/auth/sessions/${id}` as "/auth/sessions", + ); + } + + setSessions(sessions.filter(x => x.id === deviceId)); + }}> <Text id="app.settings.pages.sessions.logout" /> </Button> <Tip> -- GitLab