9f0e366a9eb6939761394294b60189e074edd2d5
[motion-next.git] / server / api / authGoogle / authGoogle.controller.js
1 const a33_0x2671=['getLicense','agent','blocked','profile','blockedAt','add','catch','Setting','../../mysqldb','blockDuration','Strategy','Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.','passport-google-oauth20','passport','callbackURL','map','disabled','email','clientID','moment','emails','user','findOne','admin','clientSecret','clearBlockUser','login','/login','../../config/utils','Use','allowedLoginAttempts','google','then','secret','authenticate'];(function(_0x4f2511,_0x2671c2){const _0x430075=function(_0x4f6dce){while(--_0x4f6dce){_0x4f2511['push'](_0x4f2511['shift']());}};_0x430075(++_0x2671c2);}(a33_0x2671,0x1e7));const a33_0x4300=function(_0x4f2511,_0x2671c2){_0x4f2511=_0x4f2511-0x0;let _0x430075=a33_0x2671[_0x4f2511];return _0x430075;};const _0xfc0dfc=a33_0x4300;'use strict';const _=require('lodash'),passport=require(_0xfc0dfc('0x10')),GoogleStrategy=require(_0xfc0dfc('0xf'))[_0xfc0dfc('0xd')],moment=require(_0xfc0dfc('0x16')),db=require(_0xfc0dfc('0xb'))['db'],config=require('../../config/environment'),utils=require(_0xfc0dfc('0x1f')),{Op}=require('sequelize');exports[_0xfc0dfc('0x1d')]=passport['authenticate'](_0xfc0dfc('0x22'),{'failureRedirect':_0xfc0dfc('0x1e'),'scope':[_0xfc0dfc('0x6'),_0xfc0dfc('0x14')],'session':![]}),exports['callback']=passport[_0xfc0dfc('0x2')](_0xfc0dfc('0x22'),{'failureRedirect':_0xfc0dfc('0x1e'),'session':![]}),passport['use'](new GoogleStrategy({'clientID':config[_0xfc0dfc('0x22')]?config[_0xfc0dfc('0x22')][_0xfc0dfc('0x15')]:'id','clientSecret':config[_0xfc0dfc('0x22')]?config[_0xfc0dfc('0x22')][_0xfc0dfc('0x1b')]:_0xfc0dfc('0x1'),'callbackURL':config['google']?config[_0xfc0dfc('0x22')][_0xfc0dfc('0x11')]:''},function(_0x4f6dce,_0x1e6a16,_0x459349,_0x4a98d6){const _0x5b1360=_0xfc0dfc;let _0x111a25,_0x110fdd;return db[_0x5b1360('0xa')][_0x5b1360('0x19')]({'where':{'id':0x1},'attributes':[_0x5b1360('0x21'),_0x5b1360('0xc')],'raw':!![]})[_0x5b1360('0x0')](function(_0x135ba4){const _0x320883=_0x5b1360;return _0x111a25=_0x135ba4,db[_0x320883('0x20')][_0x320883('0x19')]({'where':{'email':_[_0x320883('0x12')](_0x459349[_0x320883('0x17')],'value'),'role':{[Op['or']]:[_0x320883('0x1a'),_0x320883('0x18'),_0x320883('0x4')]}}});})['then'](function(_0x5257a2){const _0x333dc0=_0x5b1360;_0x110fdd=_0x5257a2;if(_0x110fdd){if(_0x110fdd[_0x333dc0('0x13')])return _0x4a98d6('Incorrect\x20username\x20and/or\x20password.\x20Please\x20retry\x20again\x20or\x20contact\x20the\x20administrator.');else return _0x111a25['blockDuration']>0x0?_0x110fdd[_0x333dc0('0x5')]?moment(_0x110fdd[_0x333dc0('0x7')])[_0x333dc0('0x8')](_0x111a25[_0x333dc0('0xc')],'minutes')>moment()?_0x4a98d6(_0x333dc0('0xe')):utils[_0x333dc0('0x1c')](_0x110fdd,0x0,![],null)[_0x333dc0('0x0')](function(){const _0x27bf08=_0x333dc0;return utils[_0x27bf08('0x3')](_0x110fdd);})[_0x333dc0('0x0')](function(){return _0x4a98d6(null,_0x110fdd);}):utils[_0x333dc0('0x3')](_0x110fdd)[_0x333dc0('0x0')](function(){return _0x4a98d6(null,_0x110fdd);}):utils['getLicense'](_0x110fdd)[_0x333dc0('0x0')](function(){return _0x4a98d6(null,_0x110fdd);});}return _0x4a98d6(_0x333dc0('0xe'));})[_0x5b1360('0x9')](function(_0x4b7fdf){_0x4a98d6(_0x4b7fdf);});}));