mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
fix(api): redirect to frontend on spotify auth error
This commit is contained in:
parent
b6eef7f090
commit
cffddedc81
2 changed files with 34 additions and 4 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import { Controller, Get, Res, UseGuards } from "@nestjs/common";
|
||||
import { Controller, Get, Res, UseFilters, UseGuards } from "@nestjs/common";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import { AuthGuard } from "@nestjs/passport";
|
||||
import { Response } from "express";
|
||||
import { User } from "../users/user.entity";
|
||||
import { ReqUser } from "./decorators/req-user.decorator";
|
||||
import { AuthService } from "./auth.service";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import { ReqUser } from "./decorators/req-user.decorator";
|
||||
import { SpotifyAuthFilter } from "./spotify.filter";
|
||||
|
||||
@Controller("api/v1/auth")
|
||||
export class AuthController {
|
||||
|
|
@ -20,6 +21,7 @@ export class AuthController {
|
|||
}
|
||||
|
||||
@Get("spotify/callback")
|
||||
@UseFilters(SpotifyAuthFilter)
|
||||
@UseGuards(AuthGuard("spotify"))
|
||||
async spotifyCallback(@ReqUser() user: User, @Res() res: Response) {
|
||||
const { accessToken } = await this.authService.createToken(user);
|
||||
|
|
@ -35,6 +37,6 @@ export class AuthController {
|
|||
});
|
||||
|
||||
// Redirect User to SPA
|
||||
res.redirect("/");
|
||||
res.redirect("/login/success?type=spotify");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue