[next] Email Login (#2138)

* feat: added email scope to google login

* feat: enabled email for facebook

* fix: added fallback
This commit is contained in:
Wyatt Johnson
2018-12-21 16:26:01 +00:00
committed by GitHub
parent 98a8c8dc71
commit 0e941222c5
3 changed files with 23 additions and 6 deletions
@@ -29,6 +29,16 @@ export default class FacebookStrategy extends OAuth2Strategy<
> {
public name = "facebook";
constructor(options: FacebookStrategyOptions) {
super({
...options,
authenticateOptions: {
display: "popup",
scope: ["email"],
},
});
}
protected getIntegration = (integrations: GQLAuthIntegrations) =>
integrations.facebook;
@@ -38,7 +38,9 @@ export default class GoogleStrategy extends OAuth2Strategy<
constructor(options: GoogleStrategyOptions) {
super({
...options,
scope: ["profile"],
authenticateOptions: {
scope: ["profile", "email"],
},
});
}
@@ -21,7 +21,7 @@ export interface OAuth2StrategyOptions {
config: Config;
mongo: Db;
tenantCache: TenantCache;
scope?: string[];
authenticateOptions?: Record<string, any>;
}
export default abstract class OAuth2Strategy<
@@ -31,15 +31,20 @@ export default abstract class OAuth2Strategy<
protected config: Config;
protected mongo: Db;
protected cache: TenantCacheAdapter<U>;
private scope?: string[];
private authenticateOptions: Record<string, any>;
constructor({ config, mongo, tenantCache, scope }: OAuth2StrategyOptions) {
constructor({
config,
mongo,
tenantCache,
authenticateOptions,
}: OAuth2StrategyOptions) {
super();
this.config = config;
this.mongo = mongo;
this.cache = new TenantCacheAdapter(tenantCache);
this.scope = scope;
this.authenticateOptions = authenticateOptions || {};
}
protected abstract getIntegration(integrations: AuthIntegrations): T;
@@ -119,7 +124,7 @@ export default abstract class OAuth2Strategy<
strategy.authenticate(req, {
session: false,
scope: this.scope,
...this.authenticateOptions,
});
} catch (err) {
return this.error(err);