Fixed signup for gitlab and github

This commit is contained in:
Daniel Hougaard
2024-01-27 12:38:23 +05:30
committed by Akhil Mohan
parent 295c1e5d4a
commit 4f619d7e48
@@ -72,6 +72,7 @@ export const registerSsoRouter = async (server: FastifyZodProvider) => {
scope: ["user:email"] scope: ["user:email"]
}, },
async (req, accessToken, _refreshToken, profile, cb) => { async (req, accessToken, _refreshToken, profile, cb) => {
const serverCfg = server.services.superAdmin.getServerCfg();
const ghEmails = await fetchGithubEmails(accessToken); const ghEmails = await fetchGithubEmails(accessToken);
const { email } = ghEmails.filter((gitHubEmail) => gitHubEmail.primary)[0]; const { email } = ghEmails.filter((gitHubEmail) => gitHubEmail.primary)[0];
@@ -80,7 +81,8 @@ export const registerSsoRouter = async (server: FastifyZodProvider) => {
firstName: profile.displayName, firstName: profile.displayName,
lastName: "", lastName: "",
authMethod: AuthMethod.GITHUB, authMethod: AuthMethod.GITHUB,
callbackPort: req.query.state as string callbackPort: req.query.state as string,
isSignupAllowed: Boolean(serverCfg.allowSignUp)
}); });
return cb(null, { isUserCompleted, providerAuthToken }); return cb(null, { isUserCompleted, providerAuthToken });
@@ -106,13 +108,15 @@ export const registerSsoRouter = async (server: FastifyZodProvider) => {
baseURL: appCfg.CLIENT_GITLAB_LOGIN_URL baseURL: appCfg.CLIENT_GITLAB_LOGIN_URL
}, },
async (req: any, _accessToken: string, _refreshToken: string, profile: any, cb: any) => { async (req: any, _accessToken: string, _refreshToken: string, profile: any, cb: any) => {
const serverCfg = server.services.superAdmin.getServerCfg();
const email = profile.emails[0].value; const email = profile.emails[0].value;
const { isUserCompleted, providerAuthToken } = await server.services.login.oauth2Login({ const { isUserCompleted, providerAuthToken } = await server.services.login.oauth2Login({
email, email,
firstName: profile.displayName, firstName: profile.displayName,
lastName: "", lastName: "",
authMethod: AuthMethod.GITLAB, authMethod: AuthMethod.GITLAB,
callbackPort: req.query.state as string callbackPort: req.query.state as string,
isSignupAllowed: Boolean(serverCfg.allowSignUp)
}); });
return cb(null, { isUserCompleted, providerAuthToken }); return cb(null, { isUserCompleted, providerAuthToken });