Implement sign out
This commit is contained in:
parent
cac25472c6
commit
0e3957fd45
3 changed files with 16 additions and 0 deletions
13
backend/src/routes/website-api/developer/sign-out.ts
Normal file
13
backend/src/routes/website-api/developer/sign-out.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import type { MyFastifyInstance } from '../../../types';
|
||||
import { getSessionData } from '../../../utils';
|
||||
|
||||
export default function registerSignOut(server: MyFastifyInstance): void {
|
||||
server.get('/developer/sign-out', async (
|
||||
request,
|
||||
reply,
|
||||
) => {
|
||||
const sessionData = getSessionData(request.session);
|
||||
sessionData.loginState = null;
|
||||
await reply.redirect('/developer');
|
||||
});
|
||||
}
|
|
@ -6,6 +6,7 @@ import registerAllow from './allow';
|
|||
import registerDeny from './deny';
|
||||
import registerGitHubCallback from './developer/github-callback';
|
||||
import registerGitHubSignIn from './developer/github-sign-in';
|
||||
import registerSignOut from './developer/sign-out';
|
||||
import CreateUserResolver from './resolvers/authenticate-prompt/create-user-resolver';
|
||||
import LoginResolver from './resolvers/authenticate-prompt/login-resolver';
|
||||
import PromptInfoResolver from './resolvers/authenticate-prompt/prompt-info-resolver';
|
||||
|
@ -42,4 +43,5 @@ export default async function registerWebsiteApi(server: MyFastifyInstance): Pro
|
|||
|
||||
registerGitHubSignIn(server);
|
||||
registerGitHubCallback(server);
|
||||
registerSignOut(server);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<v-btn icon>
|
||||
<v-img :src="loginState.avatarUrl" :width="48" />
|
||||
</v-btn>
|
||||
<v-btn outlined href="/api/website/developer/sign-out">Sign out</v-btn>
|
||||
</v-app-bar>
|
||||
<router-view />
|
||||
</v-app>
|
||||
|
|
Loading…
Reference in a new issue