29093879eee23799fb6c5763e26546d40a5e147c
[motion-next.git] / server / api / authGoogle / authGoogle.controller.js
1 const a33_0x5af3=['allowedLoginAttempts','value','use','secret','../../config/utils','../../mysqldb','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','map','email','callback','admin','clientID','getLicense','minutes','Strategy','add','profile','authenticate','blockDuration','user','disabled','moment','/login','then','passport-google-oauth20','login','findOne','agent','lodash','Use','google','emails','Setting'];(function(_0x318604,_0x5af370){const _0x37326e=function(_0x34010e){while(--_0x34010e){_0x318604['push'](_0x318604['shift']());}};_0x37326e(++_0x5af370);}(a33_0x5af3,0x154));const a33_0x3732=function(_0x318604,_0x5af370){_0x318604=_0x318604-0x0;let _0x37326e=a33_0x5af3[_0x318604];return _0x37326e;};const _0x31ac2f=a33_0x3732;'use strict';const _=require(_0x31ac2f('0x12')),passport=require('passport'),GoogleStrategy=require(_0x31ac2f('0xe'))[_0x31ac2f('0x4')],moment=require(_0x31ac2f('0xb')),db=require(_0x31ac2f('0x1c'))['db'],config=require('../../config/environment'),utils=require(_0x31ac2f('0x1b')),{Op}=require('sequelize');exports[_0x31ac2f('0xf')]=passport[_0x31ac2f('0x7')]('google',{'failureRedirect':_0x31ac2f('0xc'),'scope':[_0x31ac2f('0x6'),_0x31ac2f('0x1f')],'session':![]}),exports[_0x31ac2f('0x20')]=passport[_0x31ac2f('0x7')](_0x31ac2f('0x14'),{'failureRedirect':_0x31ac2f('0xc'),'session':![]}),passport[_0x31ac2f('0x19')](new GoogleStrategy({'clientID':config[_0x31ac2f('0x14')]?config[_0x31ac2f('0x14')][_0x31ac2f('0x1')]:'id','clientSecret':config[_0x31ac2f('0x14')]?config['google']['clientSecret']:_0x31ac2f('0x1a'),'callbackURL':config[_0x31ac2f('0x14')]?config[_0x31ac2f('0x14')]['callbackURL']:''},function(_0x34010e,_0x2c3366,_0x55bd1f,_0x2c6039){const _0x472a24=_0x31ac2f;let _0x4fc85a,_0x2e64d8;return db[_0x472a24('0x16')][_0x472a24('0x10')]({'where':{'id':0x1},'attributes':[_0x472a24('0x17'),'blockDuration'],'raw':!![]})[_0x472a24('0xd')](function(_0x42ea94){const _0x4df009=_0x472a24;return _0x4fc85a=_0x42ea94,db[_0x4df009('0x13')]['findOne']({'where':{'email':_[_0x4df009('0x1e')](_0x55bd1f[_0x4df009('0x15')],_0x4df009('0x18')),'role':{[Op['or']]:[_0x4df009('0x0'),_0x4df009('0x9'),_0x4df009('0x11')]}}});})[_0x472a24('0xd')](function(_0x5934cf){const _0x57e225=_0x472a24;_0x2e64d8=_0x5934cf;if(_0x2e64d8){if(_0x2e64d8[_0x57e225('0xa')])return _0x2c6039(_0x57e225('0x1d'));else return _0x4fc85a['blockDuration']>0x0?_0x2e64d8['blocked']?moment(_0x2e64d8['blockedAt'])[_0x57e225('0x5')](_0x4fc85a[_0x57e225('0x8')],_0x57e225('0x3'))>moment()?_0x2c6039('Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.'):utils['clearBlockUser'](_0x2e64d8,0x0,![],null)[_0x57e225('0xd')](function(){return utils['getLicense'](_0x2e64d8);})[_0x57e225('0xd')](function(){return _0x2c6039(null,_0x2e64d8);}):utils['getLicense'](_0x2e64d8)['then'](function(){return _0x2c6039(null,_0x2e64d8);}):utils[_0x57e225('0x2')](_0x2e64d8)[_0x57e225('0xd')](function(){return _0x2c6039(null,_0x2e64d8);});}return _0x2c6039(_0x57e225('0x1d'));})['catch'](function(_0x530c41){_0x2c6039(_0x530c41);});}));