mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
chore(api): update dependencies
This commit is contained in:
parent
05f230a7ce
commit
d881a78757
37 changed files with 4804 additions and 2700 deletions
|
|
@ -31,7 +31,7 @@ export class AuthController {
|
|||
maxAge: 15 * 60 * 1000,
|
||||
|
||||
// Must be readable by SPA
|
||||
httpOnly: false
|
||||
httpOnly: false,
|
||||
});
|
||||
|
||||
// Redirect User to SPA
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ import { SpotifyStrategy } from "./spotify.strategy";
|
|||
JwtModule.registerAsync({
|
||||
useFactory: (config: ConfigService) => ({
|
||||
secret: config.get<string>("JWT_SECRET"),
|
||||
signOptions: { expiresIn: config.get<string>("JWT_EXPIRATION_TIME") }
|
||||
signOptions: { expiresIn: config.get<string>("JWT_EXPIRATION_TIME") },
|
||||
}),
|
||||
inject: [ConfigService]
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
UsersModule
|
||||
UsersModule,
|
||||
],
|
||||
providers: [AuthService, SpotifyStrategy, JwtStrategy],
|
||||
exports: [PassportModule],
|
||||
controllers: [AuthController]
|
||||
controllers: [AuthController],
|
||||
})
|
||||
export class AuthModule {}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe("AuthService", () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [AuthService]
|
||||
providers: [AuthService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<AuthService>(AuthService);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export class AuthService {
|
|||
async spotifyLogin({
|
||||
accessToken,
|
||||
refreshToken,
|
||||
profile
|
||||
profile,
|
||||
}: LoginDto): Promise<User> {
|
||||
const user = await this.usersService.createOrUpdate({
|
||||
displayName: profile.displayName,
|
||||
|
|
@ -22,8 +22,8 @@ export class AuthService {
|
|||
spotify: {
|
||||
id: profile.id,
|
||||
accessToken,
|
||||
refreshToken
|
||||
}
|
||||
refreshToken,
|
||||
},
|
||||
});
|
||||
|
||||
return user;
|
||||
|
|
@ -33,7 +33,7 @@ export class AuthService {
|
|||
const payload = {
|
||||
sub: user.id,
|
||||
name: user.displayName,
|
||||
picture: user.photo
|
||||
picture: user.photo,
|
||||
};
|
||||
|
||||
const token = await this.jwtService.signAsync(payload);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
import { createParamDecorator } from "@nestjs/common";
|
||||
import { createParamDecorator, ExecutionContext } from "@nestjs/common";
|
||||
|
||||
export const ReqUser = createParamDecorator((data, req) => req.user);
|
||||
export const ReqUser = createParamDecorator<void>(
|
||||
(_: void, ctx: ExecutionContext) => {
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
return request.user;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ import { AuthService } from "./auth.service";
|
|||
@Injectable()
|
||||
export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
constructor(
|
||||
private readonly config: ConfigService,
|
||||
private readonly authService: AuthService
|
||||
private readonly authService: AuthService,
|
||||
config: ConfigService
|
||||
) {
|
||||
super({
|
||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
ignoreExpiration: false,
|
||||
secretOrKey: config.get<string>("JWT_SECRET")
|
||||
secretOrKey: config.get<string>("JWT_SECRET"),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ export class SpotifyStrategy extends PassportStrategy(Strategy) {
|
|||
super({
|
||||
clientID: config.get<string>("SPOTIFY_CLIENT_ID"),
|
||||
clientSecret: config.get<string>("SPOTIFY_CLIENT_SECRET"),
|
||||
callbackURL: `${config.get<string>("BASE_DOMAIN") ||
|
||||
"http://localhost:3000"}/api/v1/auth/spotify/callback`,
|
||||
callbackURL: `${
|
||||
config.get<string>("BASE_DOMAIN") || "http://localhost:3000"
|
||||
}/api/v1/auth/spotify/callback`,
|
||||
scope: [
|
||||
"user-read-private",
|
||||
"user-read-email",
|
||||
"user-read-recently-played"
|
||||
]
|
||||
"user-read-recently-played",
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ export class SpotifyStrategy extends PassportStrategy(Strategy) {
|
|||
return await this.authService.spotifyLogin({
|
||||
accessToken,
|
||||
refreshToken,
|
||||
profile
|
||||
profile,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue