cb66d898168a7975a66167e853567e2d17bb94b8
[motion-next.git] / server / api / authGoogle / authGoogle.controller.js
1 const a33_0x5229=['Strategy','login','blockedAt','profile','blocked','emails','agent','email','/login','sequelize','callbackURL','value','admin','google','disabled','map','../../mysqldb','../../config/utils','catch','passport-google-oauth20','Setting','add','getLicense','../../config/environment','clientID','Use','authenticate','allowedLoginAttempts','blockDuration','findOne','moment','callback','then','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','clientSecret','lodash','user'];(function(_0x4a2d8f,_0x5229ea){const _0x171efd=function(_0x4477a0){while(--_0x4477a0){_0x4a2d8f['push'](_0x4a2d8f['shift']());}};_0x171efd(++_0x5229ea);}(a33_0x5229,0x177));const a33_0x171e=function(_0x4a2d8f,_0x5229ea){_0x4a2d8f=_0x4a2d8f-0x0;let _0x171efd=a33_0x5229[_0x4a2d8f];return _0x171efd;};const _0x484e7f=a33_0x171e;'use strict';const _=require(_0x484e7f('0x1e')),passport=require('passport'),GoogleStrategy=require(_0x484e7f('0xe'))[_0x484e7f('0x20')],moment=require(_0x484e7f('0x19')),db=require(_0x484e7f('0xb'))['db'],config=require(_0x484e7f('0x12')),utils=require(_0x484e7f('0xc')),{Op}=require(_0x484e7f('0x4'));exports[_0x484e7f('0x21')]=passport[_0x484e7f('0x15')](_0x484e7f('0x8'),{'failureRedirect':_0x484e7f('0x3'),'scope':[_0x484e7f('0x23'),_0x484e7f('0x2')],'session':![]}),exports[_0x484e7f('0x1a')]=passport['authenticate'](_0x484e7f('0x8'),{'failureRedirect':_0x484e7f('0x3'),'session':![]}),passport['use'](new GoogleStrategy({'clientID':config['google']?config[_0x484e7f('0x8')][_0x484e7f('0x13')]:'id','clientSecret':config[_0x484e7f('0x8')]?config['google'][_0x484e7f('0x1d')]:'secret','callbackURL':config['google']?config[_0x484e7f('0x8')][_0x484e7f('0x5')]:''},function(_0x4477a0,_0x37880f,_0x50f7dc,_0x38796e){const _0x335c18=_0x484e7f;let _0x45bec8,_0x382816;return db[_0x335c18('0xf')]['findOne']({'where':{'id':0x1},'attributes':[_0x335c18('0x16'),_0x335c18('0x17')],'raw':!![]})[_0x335c18('0x1b')](function(_0x50f4f5){const _0x49c0ae=_0x335c18;return _0x45bec8=_0x50f4f5,db[_0x49c0ae('0x14')][_0x49c0ae('0x18')]({'where':{'email':_[_0x49c0ae('0xa')](_0x50f7dc[_0x49c0ae('0x0')],_0x49c0ae('0x6')),'role':{[Op['or']]:[_0x49c0ae('0x7'),_0x49c0ae('0x1f'),_0x49c0ae('0x1')]}}});})['then'](function(_0xb7f187){const _0x2afc8b=_0x335c18;_0x382816=_0xb7f187;if(_0x382816){if(_0x382816[_0x2afc8b('0x9')])return _0x38796e(_0x2afc8b('0x1c'));else return _0x45bec8[_0x2afc8b('0x17')]>0x0?_0x382816[_0x2afc8b('0x24')]?moment(_0x382816[_0x2afc8b('0x22')])[_0x2afc8b('0x10')](_0x45bec8['blockDuration'],'minutes')>moment()?_0x38796e(_0x2afc8b('0x1c')):utils['clearBlockUser'](_0x382816,0x0,![],null)[_0x2afc8b('0x1b')](function(){return utils['getLicense'](_0x382816);})[_0x2afc8b('0x1b')](function(){return _0x38796e(null,_0x382816);}):utils[_0x2afc8b('0x11')](_0x382816)['then'](function(){return _0x38796e(null,_0x382816);}):utils[_0x2afc8b('0x11')](_0x382816)[_0x2afc8b('0x1b')](function(){return _0x38796e(null,_0x382816);});}return _0x38796e(_0x2afc8b('0x1c'));})[_0x335c18('0xd')](function(_0x4cdb7b){_0x38796e(_0x4cdb7b);});}));