@@ -336,9 +336,10 @@ module.exports = {
336336 client_id : ctx . meta . isAdmin
337337 ? process . env . ADMIN_GITHUB_OAUTH_CLIENT_ID
338338 : process . env . GITHUB_OAUTH_CLIENT_ID ,
339- client_secret : ctx . meta . isAdmin
340- ? process . env . ADMIN_GITHUB_OAUTH_CLIENT_SECRET
341- : process . env . GITHUB_OAUTH_CLIENT_SECRET ,
339+ client_secret : this . getClientSecret (
340+ isTerminal ,
341+ ctx . meta . isAdmin
342+ ) ,
342343 code,
343344 } ,
344345 decompress : false ,
@@ -400,7 +401,7 @@ module.exports = {
400401 console . error ( error . response . headers ) ;
401402
402403 throw new MoleculerError (
403- 'Error occured trying to retrieve github user info' ,
404+ 'Error occurred trying to retrieve github user info' ,
404405 500 ,
405406 'github-user-retrieval'
406407 ) ;
@@ -435,7 +436,7 @@ module.exports = {
435436 console . error ( error . response . headers ) ;
436437
437438 throw new MoleculerError (
438- 'Error occured trying to retrieve github user emails' ,
439+ 'Error occurred trying to retrieve github user emails' ,
439440 500 ,
440441 'github-user-emails-retrieval'
441442 ) ;
@@ -506,7 +507,7 @@ module.exports = {
506507 get (
507508 accessTokenResult ,
508509 'error.response.data.error_description'
509- ) || `Error occured calling https://gitlab.com/oauth/token` ;
510+ ) || `Error occurred calling https://gitlab.com/oauth/token` ;
510511
511512 throw new MoleculerError (
512513 message ,
@@ -542,7 +543,7 @@ module.exports = {
542543 console . error ( error . response . headers ) ;
543544
544545 throw new MoleculerError (
545- 'Error occured trying to retrieve gitlab user info' ,
546+ 'Error occurred trying to retrieve gitlab user info' ,
546547 500 ,
547548 'github-user-retrieval'
548549 ) ;
@@ -772,14 +773,14 @@ module.exports = {
772773 async handler ( ctx : Context ) {
773774 // @ts -ignore
774775 const { provider } : { provider : string } = ctx . params ;
775- const randomNonce = randomCode ( 10 ) ;
776+ const randomNonce = randomCode ( 10 ) ;
776777
777778 switch ( provider . toLowerCase ( ) ) {
778779 case 'github' :
779780 // @ts -ignore
780781 ctx . meta . $statusCode = 303 ;
781782 // @ts -ignore
782- ctx . meta . $location = `https://github.com/login/oauth/authorize?client_id=${ process . env . GITHUB_OAUTH_CLIENT_ID } &state=${ randomNonce } &scope=read:user user:email` ;
783+ ctx . meta . $location = `https://github.com/login/oauth/authorize?client_id=${ process . env . GITHUB_OAUTH_CLIENT_CLI_ID } &state=${ randomNonce } &scope=read:user user:email` ;
783784 break ;
784785 default :
785786 throw new AuthGenericError ( ) ;
@@ -916,6 +917,11 @@ module.exports = {
916917 } ,
917918
918919 methods : {
920+ getClientSecret ( isTerminal : boolean , isAdmin : boolean ) {
921+ if ( isTerminal ) return process . env . GITHUB_OAUTH_CLIENT_CLI_SECRET ;
922+ if ( isAdmin ) return process . env . ADMIN_GITHUB_OAUTH_CLIENT_SECRET ;
923+ return process . env . GITHUB_OAUTH_CLIENT_SECRET ;
924+ } ,
919925 async createOrUpdateUser ( {
920926 ctx,
921927 provider,
0 commit comments