Skip to content

Commit 227870a

Browse files
committed
fix issues suggested by coderabbit
1 parent 33cb3db commit 227870a

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

apps/server/src/auth/auth.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ export class AuthService {
200200
}
201201

202202
if (
203+
this.configService.get("OPENID_AUTHORIZATION_URL") &&
204+
this.configService.get("OPENID_ISSUER") &&
205+
this.configService.get("OPENID_TOKEN_URL") &&
206+
this.configService.get("OPENID_USER_INFO_URL") &&
203207
this.configService.get("OPENID_CLIENT_ID") &&
204208
this.configService.get("OPENID_CLIENT_SECRET") &&
205209
this.configService.get("OPENID_CALLBACK_URL")

apps/server/src/auth/strategy/github.strategy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export class GitHubStrategy extends PassportStrategy(Strategy, "github") {
3333
if (!email) throw new BadRequestException(ErrorMessage.InvalidCredentials);
3434

3535
try {
36-
const user =
36+
user =
3737
(await this.userService.findOneByIdentifier(email)) ??
38-
(username && (await this.userService.findOneByIdentifier(username)));
38+
(username ? await this.userService.findOneByIdentifier(username) : null);
3939

40-
if (!user) throw new Error(ErrorMessage.InvalidCredentials);
40+
if (!user) throw new BadRequestException(ErrorMessage.InvalidCredentials);
4141

4242
done(null, user);
4343
} catch {

apps/server/src/auth/strategy/google.strategy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export class GoogleStrategy extends PassportStrategy(Strategy, "google") {
3333
if (!email) throw new BadRequestException(ErrorMessage.InvalidCredentials);
3434

3535
try {
36-
const user =
36+
user =
3737
(await this.userService.findOneByIdentifier(email)) ??
38-
(username && (await this.userService.findOneByIdentifier(username)));
38+
(username ? await this.userService.findOneByIdentifier(username) : null);
3939

40-
if (!user) throw new Error(ErrorMessage.InvalidCredentials);
40+
if (!user) throw new BadRequestException(ErrorMessage.InvalidCredentials);
4141

4242
done(null, user);
4343
} catch {

apps/server/src/auth/strategy/openid.strategy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ export class OpenIDStrategy extends PassportStrategy(Strategy, "openid") {
3737
) {
3838
const { displayName, emails, photos, username } = profile;
3939

40-
const email = emails?.[0].value ?? `${username}@github.com`;
40+
const email = emails?.[0].value ?? `${username}@openid.com`;
4141
const picture = photos?.[0].value;
4242

4343
let user: User | null = null;
4444

4545
if (!email) throw new BadRequestException(ErrorMessage.InvalidCredentials);
4646

4747
try {
48-
const user =
48+
user =
4949
(await this.userService.findOneByIdentifier(email)) ??
50-
(username && (await this.userService.findOneByIdentifier(username)));
50+
(username ? await this.userService.findOneByIdentifier(username) : null);
5151

52-
if (!user) throw new Error(ErrorMessage.InvalidCredentials);
52+
if (!user) throw new BadRequestException(ErrorMessage.InvalidCredentials);
5353

5454
done(null, user);
5555
} catch {

0 commit comments

Comments
 (0)