mirror of
https://github.com/wassname/talk.git
synced 2026-07-24 13:20:47 +08:00
[next] Email Login (#2138)
* feat: added email scope to google login * feat: enabled email for facebook * fix: added fallback
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user