- fixes #2153, attempt to fix 401 unauthorized error when implementing OIDC

This commit is contained in:
Amruth Pillai
2025-01-15 16:32:43 +01:00
parent 9a34e4af27
commit 63db927924
16 changed files with 219 additions and 196 deletions
@@ -1,5 +1,6 @@
import { BadRequestException, Injectable } from "@nestjs/common";
import { BadRequestException, Injectable, Logger } from "@nestjs/common";
import { PassportStrategy } from "@nestjs/passport";
import { createId } from "@paralleldrive/cuid2";
import { User } from "@prisma/client";
import { ErrorMessage, processUsername } from "@reactive-resume/utils";
import { Profile, Strategy, StrategyOptions } from "passport-github2";
@@ -46,15 +47,17 @@ export class GitHubStrategy extends PassportStrategy(Strategy, "github") {
email,
picture,
locale: "en-US",
name: displayName,
provider: "github",
name: displayName || createId(),
emailVerified: true, // auto-verify emails
username: processUsername(username ?? email.split("@")[0]),
secrets: { create: {} },
});
done(null, user);
} catch {
} catch (error) {
Logger.error(error);
throw new BadRequestException(ErrorMessage.UserAlreadyExists);
}
}