Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(authentication): provider email/id matching not working properly #601

Merged
merged 45 commits into from
Apr 21, 2023
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
030b3a5
refactor(grpc-sdk)!: remove module management specifics and keep sdk-…
kkopanidis Apr 7, 2023
4a1cccf
refactor(grpc-sdk): move sdk non-essential to module-tools
kkopanidis Apr 15, 2023
46958bc
refactor(module-tools): move convictConfigParser to a separate file
kkopanidis Apr 15, 2023
7ee85bc
refactor(grpc-sdk): add metrics interface and metrics property
kkopanidis Apr 15, 2023
20eea18
chore(grpc-sdk): reformat and cleanup code
kkopanidis Apr 15, 2023
8996f67
chore(module-tools): reformat and cleanup code
kkopanidis Apr 15, 2023
3372df6
feat(grpc-sdk): add winston in IConduitLogger
kkopanidis Apr 15, 2023
c39f37b
chore(grpc-sdk,module-tools): cleanup dependencies
kkopanidis Apr 15, 2023
2c37e00
chore: add module-tools dependency to all packages
kkopanidis Apr 15, 2023
32dd418
refactor(grpc-sdk): exported Headers in router types did not include …
kkopanidis Apr 15, 2023
8f9ac93
refactor(authentication): use module-tools
kkopanidis Apr 15, 2023
24ee4d2
chore(authentication): optimize imports & cleanup code
kkopanidis Apr 15, 2023
af1d7e8
refactor(authorization): use module-tools
kkopanidis Apr 15, 2023
ea94d0a
refactor(chat): use module-tools
kkopanidis Apr 15, 2023
a8cba23
chore(chat): optimize imports & cleanup code
kkopanidis Apr 15, 2023
c1ffb2c
refactor(database): use module-tools
kkopanidis Apr 15, 2023
8084acc
refactor(email): use module-tools
kkopanidis Apr 15, 2023
497c954
chore(email): optimize imports & cleanup code
kkopanidis Apr 15, 2023
d74fc69
refactor(forms): use module-tools
kkopanidis Apr 15, 2023
3dca584
refactor(functions): use module-tools
kkopanidis Apr 15, 2023
08c9dce
refactor(push-notifications): use module-tools
kkopanidis Apr 15, 2023
8a208a3
refactor(router): use module-tools
kkopanidis Apr 15, 2023
87c7e25
refactor(sms): use module-tools
kkopanidis Apr 15, 2023
8ef5814
refactor(storage): use module-tools
kkopanidis Apr 15, 2023
6be1302
refactor(commons): use module-tools
kkopanidis Apr 15, 2023
f95f4da
fix(grpc-sdk): used MetricType in metric interface
kkopanidis Apr 15, 2023
e69468f
fix(module-tools): utilities not being exported
kkopanidis Apr 15, 2023
56d0b17
refactor(module-tools): create sdk init utility
kkopanidis Apr 15, 2023
aebfafd
refactor(admin,core): use module-tools
kkopanidis Apr 15, 2023
0e30244
chore(core): reformat and cleanup code/imports
kkopanidis Apr 15, 2023
ae40d09
chore(admin): reformat and cleanup code/imports
kkopanidis Apr 15, 2023
79597a8
Merge branch 'main' into sdk-split
kkopanidis Apr 15, 2023
18fdafa
fix(storage): merge issues
kkopanidis Apr 15, 2023
d391dd5
fix(module-tools): wrong MetricType usage
kkopanidis Apr 15, 2023
56b48a6
refactor(grpc-sdk): add module.proto to streamline setConfig requests
kkopanidis Apr 18, 2023
40d72cc
fix(module-tools): previously removed copy action
kkopanidis Apr 19, 2023
b9bc25f
fix(module-tools): module service init
kkopanidis Apr 19, 2023
39b206d
Merge branch 'main' into sdk-cleanup
kkopanidis Apr 19, 2023
887cca9
Merge branch 'main' into sdk-cleanup
kkopanidis Apr 19, 2023
0624b44
refactor(forms,functions): remove empty proto files
kkopanidis Apr 19, 2023
391020a
Merge branch 'main' into sdk-cleanup
kkopanidis Apr 20, 2023
c0bd679
fix: build issues
kkopanidis Apr 20, 2023
cadc252
fix: makefile
kkopanidis Apr 21, 2023
3b275ac
fix(authentication): provider email/id matching not working properly
kkopanidis Apr 21, 2023
1708714
Merge branch 'main' into fix-auth
kkopanidis Apr 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions modules/authentication/src/handlers/oauth2/OAuth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,22 @@ export abstract class OAuth2<T, S extends OAuth2Settings>

async createOrUpdateUser(payload: Payload<T>, invitationToken?: string): Promise<User> {
let user: User | null = null;
if (payload.hasOwnProperty('email')) {
if (payload.hasOwnProperty('email') && !isNil(payload.email)) {
user = await User.getInstance().findOne({
email: payload.email,
});
} else if (payload.hasOwnProperty('id') && !payload.hasOwnProperty('email')) {
} else if (
payload.hasOwnProperty('id') &&
(!payload.hasOwnProperty('email') || isNil(payload.email))
) {
user = await User.getInstance().findOne({
[this.providerName]: { id: payload.id },
});
} else {
throw new GrpcError(
status.INVALID_ARGUMENT,
'No email or id received from provider',
);
}
if (!isNil(user)) {
if (!user!.active) throw new GrpcError(status.PERMISSION_DENIED, 'Inactive user');
Expand Down