release: v4.1.0

This commit is contained in:
Amruth Pillai
2024-05-05 14:55:06 +02:00
parent 68252c35fc
commit e87b05a93a
282 changed files with 11461 additions and 10713 deletions
@@ -1,8 +1,7 @@
import { BadRequestException, Injectable, UnauthorizedException } from "@nestjs/common";
import { BadRequestException, Injectable } from "@nestjs/common";
import { PassportStrategy } from "@nestjs/passport";
import { User } from "@prisma/client";
import { processUsername } from "@reactive-resume/utils";
import { ErrorMessage } from "@reactive-resume/utils";
import { ErrorMessage, processUsername } from "@reactive-resume/utils";
import { Profile, Strategy, StrategyOptions } from "passport-github2";
import { UserService } from "@/server/user/user.service";
@@ -31,17 +30,17 @@ export class GitHubStrategy extends PassportStrategy(Strategy, "github") {
let user: User | null = null;
if (!email || !username) throw new BadRequestException();
if (!email) throw new BadRequestException();
try {
const user =
(await this.userService.findOneByIdentifier(email)) ||
(await this.userService.findOneByIdentifier(username));
(await this.userService.findOneByIdentifier(email)) ??
(username && (await this.userService.findOneByIdentifier(username)));
if (!user) throw new UnauthorizedException();
if (!user) throw new Error("User not found.");
done(null, user);
} catch (error) {
} catch {
try {
user = await this.userService.create({
email,
@@ -55,7 +54,7 @@ export class GitHubStrategy extends PassportStrategy(Strategy, "github") {
});
done(null, user);
} catch (error) {
} catch {
throw new BadRequestException(ErrorMessage.UserAlreadyExists);
}
}