Skip to content

Commit

Permalink
feat: add signout endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
miggyalino committed Oct 27, 2024
1 parent f0f4b71 commit bf0d95f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ export class AuthController {
}
}

@Post('logout')
async logout(@Response() res: Res) {
try {
await this.authService.signOut();
return res.status(HttpStatus.OK).json({ message: 'Logout successful' });
} catch (error) {
return res
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.json({ message: error.message || 'Failed to logout' });
}
}

@Get('user')
async getUser() {
const user = await this.supabaseService.getCurrentSession();
Expand Down
5 changes: 5 additions & 0 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export class AuthService {
return;
}

async signOut() {
await this.supabaseService.signOutSupabaseUser();
return;
}

async getUserInfoBySupabaseUserId(
supabaseUserId: string,
): Promise<{ email: string; userType: string }> {
Expand Down

0 comments on commit bf0d95f

Please sign in to comment.