Created
September 20, 2021 12:18
-
-
Save xtiannyeto/e608f4634e8a0a1780347be8a3a33f23 to your computer and use it in GitHub Desktop.
Export a method which return an instance with any config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function installGoogleAuth(options: any): Promise<any> { | |
// set config | |
let GoogleAuthConfig: any = null; | |
const GoogleAuthDefaultConfig = { | |
scope: 'profile email' | |
}; | |
let prompt = 'select_account'; | |
if (typeof options === 'object') { | |
GoogleAuthConfig = Object.assign(GoogleAuthDefaultConfig, options); | |
if (options.scope) { | |
GoogleAuthConfig.scope = options.scope; | |
} | |
if (options.prompt) { | |
prompt = options.prompt; | |
} | |
if (!options.clientId) { | |
// tslint:disable-next-line | |
console.warn('clientId is required'); | |
} | |
} else { | |
// tslint:disable-next-line | |
console.warn('invalid option type. Object type accepted only'); | |
} | |
await googleAuth.load(GoogleAuthConfig, prompt); | |
return googleAuth; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment