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): wrong errors thrown in validation #188

Merged
merged 2 commits into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 4 additions & 8 deletions modules/authentication/src/handlers/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,12 @@ export class LocalHandlers implements IAuthenticationStrategy {
try {
emailConfig = await this.grpcSdk.config.get('email');
} catch (e) {
this.initialized = false;
throw ConduitError.forbidden(
'Cannot use email verification without Email module being enabled',
);
console.log('Cannot use email verification without Email module being enabled');
return (this.initialized = false);
}
if (!emailConfig.active) {
this.initialized = false;
throw ConduitError.forbidden(
'Cannot use email verification without Email module being enabled',
);
console.log('Cannot use email verification without Email module being enabled');
return (this.initialized = false);
}
}
if (!this.initialized) {
Expand Down
10 changes: 4 additions & 6 deletions modules/authentication/src/handlers/oauth2/OAuth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,19 @@ export abstract class OAuth2<T, S extends OAuth2Settings>
const authConfig = ConfigController.getInstance().config;
if (!authConfig[this.providerName].enabled) {
console.log(`${this.providerName} not active`);
throw ConduitError.forbidden(`${this.providerName} auth is deactivated`);
return (this.initialized = false);
}
if (
!authConfig[this.providerName] ||
!authConfig[this.providerName].clientId ||
!authConfig[this.providerName].clientSecret
) {
console.log(`${this.providerName} is not active`);
throw ConduitError.forbidden(
`Cannot enable ${this.providerName} auth due to missing clientId or client secret`,
);
return (this.initialized = false);
}
console.log(`${this.providerName} is active`);
this.initialized = true;
return true;

return (this.initialized = true);
}

async redirect(call: ParsedRouterRequest): Promise<UnparsedRouterResponse> {
Expand Down
3 changes: 1 addition & 2 deletions modules/authentication/src/handlers/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export class ServiceHandler implements IAuthenticationStrategy {
const authConfig = ConfigController.getInstance().config;
if (!authConfig.service.enabled) {
console.error('Service not active');
this.initialized = false;
throw ConduitError.forbidden('Service auth is deactivated');
return (this.initialized = false);
}
console.log('Service is active');
return (this.initialized = true);
Expand Down
2 changes: 1 addition & 1 deletion modules/authentication/src/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class AuthenticationRoutes {
enabled = true;
return;
})
.catch();
.catch(e => console.error(e));
},
),
);
Expand Down