Implement sign out

This commit is contained in:
Dominik Korsa 2021-02-12 12:22:01 +01:00
parent cac25472c6
commit 0e3957fd45
No known key found for this signature in database
GPG key ID: 546F986F71A6FE6E
3 changed files with 16 additions and 0 deletions

View 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');
});
}

View file

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

View file

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