-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make logout from settings modal functional #241
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Navigate } from "../../../../routing/index"; | ||
|
||
/** | ||
* redirect to login page after logout | ||
*/ | ||
export default function Logout() { | ||
return <Navigate href="/login" />; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ import bots from "./Bots"; | |
import experiments from "./Experiments"; | ||
import feedback from "./Feedback"; | ||
import language from "./Language"; | ||
import logout from "./Logout"; | ||
import native from "./Native"; | ||
import notifications from "./Notifications"; | ||
import sessions from "./Sessions"; | ||
|
@@ -196,6 +197,14 @@ const Config: SettingsConfiguration<{ server: Server }> = { | |
{ | ||
id: "logout", | ||
icon: <BiSolidExit size={20} color={theme!.colours.error} />, | ||
href: "/login", | ||
onClick: () => { | ||
const acli = getController("state"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This package should also have direct access to state and it can be called through |
||
const cli = getController("client").getCurrentClient(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. client is available through context here, add |
||
console.log(cli); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extraneous print statement |
||
acli.auth.removeSession(cli?.user?.id as string); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will remove the session from storage but not kill the active client in the client controller, which is remedied by assigning |
||
window.location.href = "/login"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should useNavigate from routing package at top of component, and then use navigate function instead of telling the browser to redirect us. |
||
}, | ||
title: ( | ||
<ColouredText colour={theme!.colours.error}> | ||
{t("app.settings.pages.logOut")} | ||
|
@@ -227,4 +236,5 @@ const ClientSettingsRouting: Record<string, Component> = { | |
sync, | ||
native, | ||
experiments, | ||
logout, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once id is omitted, this component no longer needs to be included. |
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit id, only onClick is necessary.