mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
refactor(api): remove deprecated function and rename exception
This commit is contained in:
parent
5ef650a6dc
commit
73bba4ef68
2 changed files with 3 additions and 23 deletions
|
|
@ -30,7 +30,7 @@ export class AuthService {
|
|||
profile,
|
||||
}: LoginDto): Promise<User> {
|
||||
if (!this.allowedByUserFilter(profile.id)) {
|
||||
throw new ForbiddenException("UserNotWhitelisted");
|
||||
throw new ForbiddenException("UserNotInUserFilter");
|
||||
}
|
||||
|
||||
const user = await this.usersService.createOrUpdate({
|
||||
|
|
@ -55,10 +55,7 @@ export class AuthService {
|
|||
session.user = user;
|
||||
await this.authSessionRepository.save(session);
|
||||
|
||||
const [{ refreshToken }] = await Promise.all([
|
||||
this.createRefreshToken(session),
|
||||
this.createAccessToken(session),
|
||||
]);
|
||||
const { refreshToken } = await this.createRefreshToken(session);
|
||||
|
||||
return { session, refreshToken };
|
||||
}
|
||||
|
|
@ -100,23 +97,6 @@ export class AuthService {
|
|||
return { accessToken: token };
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to createAccessToken
|
||||
* @deprecated
|
||||
* @param user
|
||||
*/
|
||||
async createToken(user: User): Promise<{ accessToken }> {
|
||||
const payload = {
|
||||
sub: user.id,
|
||||
name: user.displayName,
|
||||
picture: user.photo,
|
||||
};
|
||||
|
||||
const token = await this.jwtService.signAsync(payload);
|
||||
|
||||
return { accessToken: token };
|
||||
}
|
||||
|
||||
async findSession(id: string): Promise<AuthSession> {
|
||||
return this.authSessionRepository.findOne(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export class SpotifyAuthFilter implements ExceptionFilter {
|
|||
reason = "oauth2";
|
||||
} else if (
|
||||
exception instanceof ForbiddenException &&
|
||||
exception.message === "UserNotWhitelisted"
|
||||
exception.message === "UserNotInUserFilter"
|
||||
) {
|
||||
// User ID is not in the whitelist
|
||||
reason = "whitelist";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue