mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-17 02:01:29 +10:00
fix issues suggested by coderabbit
This commit is contained in:
@ -200,6 +200,10 @@ export class AuthService {
|
||||
}
|
||||
|
||||
if (
|
||||
this.configService.get("OPENID_AUTHORIZATION_URL") &&
|
||||
this.configService.get("OPENID_ISSUER") &&
|
||||
this.configService.get("OPENID_TOKEN_URL") &&
|
||||
this.configService.get("OPENID_USER_INFO_URL") &&
|
||||
this.configService.get("OPENID_CLIENT_ID") &&
|
||||
this.configService.get("OPENID_CLIENT_SECRET") &&
|
||||
this.configService.get("OPENID_CALLBACK_URL")
|
||||
|
||||
@ -33,11 +33,11 @@ export class GitHubStrategy extends PassportStrategy(Strategy, "github") {
|
||||
if (!email) throw new BadRequestException(ErrorMessage.InvalidCredentials);
|
||||
|
||||
try {
|
||||
const user =
|
||||
user =
|
||||
(await this.userService.findOneByIdentifier(email)) ??
|
||||
(username && (await this.userService.findOneByIdentifier(username)));
|
||||
(username ? await this.userService.findOneByIdentifier(username) : null);
|
||||
|
||||
if (!user) throw new Error(ErrorMessage.InvalidCredentials);
|
||||
if (!user) throw new BadRequestException(ErrorMessage.InvalidCredentials);
|
||||
|
||||
done(null, user);
|
||||
} catch {
|
||||
|
||||
@ -33,11 +33,11 @@ export class GoogleStrategy extends PassportStrategy(Strategy, "google") {
|
||||
if (!email) throw new BadRequestException(ErrorMessage.InvalidCredentials);
|
||||
|
||||
try {
|
||||
const user =
|
||||
user =
|
||||
(await this.userService.findOneByIdentifier(email)) ??
|
||||
(username && (await this.userService.findOneByIdentifier(username)));
|
||||
(username ? await this.userService.findOneByIdentifier(username) : null);
|
||||
|
||||
if (!user) throw new Error(ErrorMessage.InvalidCredentials);
|
||||
if (!user) throw new BadRequestException(ErrorMessage.InvalidCredentials);
|
||||
|
||||
done(null, user);
|
||||
} catch {
|
||||
|
||||
@ -37,7 +37,7 @@ export class OpenIDStrategy extends PassportStrategy(Strategy, "openid") {
|
||||
) {
|
||||
const { displayName, emails, photos, username } = profile;
|
||||
|
||||
const email = emails?.[0].value ?? `${username}@github.com`;
|
||||
const email = emails?.[0].value ?? `${username}@openid.com`;
|
||||
const picture = photos?.[0].value;
|
||||
|
||||
let user: User | null = null;
|
||||
@ -45,11 +45,11 @@ export class OpenIDStrategy extends PassportStrategy(Strategy, "openid") {
|
||||
if (!email) throw new BadRequestException(ErrorMessage.InvalidCredentials);
|
||||
|
||||
try {
|
||||
const user =
|
||||
user =
|
||||
(await this.userService.findOneByIdentifier(email)) ??
|
||||
(username && (await this.userService.findOneByIdentifier(username)));
|
||||
(username ? await this.userService.findOneByIdentifier(username) : null);
|
||||
|
||||
if (!user) throw new Error(ErrorMessage.InvalidCredentials);
|
||||
if (!user) throw new BadRequestException(ErrorMessage.InvalidCredentials);
|
||||
|
||||
done(null, user);
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user