mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
feat(auth): allow to disable OIDC user registration
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
b24f8b0a76
commit
fd1795f941
4 changed files with 80 additions and 16 deletions
|
@ -73,29 +73,30 @@ export class OidcController {
|
|||
this.logger.log('No OIDC user identifier in callback', 'callback');
|
||||
throw new UnauthorizedException('No OIDC user identifier found');
|
||||
}
|
||||
request.session.authProviderType = ProviderType.OIDC;
|
||||
const identity = await this.oidcService.getExistingOidcIdentity(
|
||||
oidcIdentifier,
|
||||
oidcUserIdentifier,
|
||||
);
|
||||
request.session.authProviderType = ProviderType.OIDC;
|
||||
const mayUpdate = this.identityService.mayUpdateIdentity(oidcIdentifier);
|
||||
if (identity !== null) {
|
||||
const user = await identity.user;
|
||||
if (mayUpdate) {
|
||||
await this.usersService.updateUser(
|
||||
user,
|
||||
userInfo.displayName,
|
||||
userInfo.email,
|
||||
userInfo.photoUrl,
|
||||
);
|
||||
}
|
||||
|
||||
request.session.username = user.username;
|
||||
return { url: '/' };
|
||||
} else {
|
||||
if (identity === null) {
|
||||
request.session.newUserData = userInfo;
|
||||
return { url: '/new-user' };
|
||||
}
|
||||
|
||||
const user = await identity.user;
|
||||
if (mayUpdate) {
|
||||
await this.usersService.updateUser(
|
||||
user,
|
||||
userInfo.displayName,
|
||||
userInfo.email,
|
||||
userInfo.photoUrl,
|
||||
);
|
||||
}
|
||||
|
||||
request.session.username = user.username;
|
||||
return { url: '/' };
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) {
|
||||
throw error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue