Built motion from commit (unavailable).|2.2.0
[motion2.git] / server / api / authGoogle / authGoogle.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xb12c=['email','callback','clientID','clientSecret','secret','callbackURL','find','map','value','user','agent','then','User\x20email\x20not\x20found!','catch','passport-google-oauth20','../../mysqldb','../../config/environment','../../components/auth/service','signToken','authenticate','google','/login'];(function(_0x17d9e3,_0x1f969c){var _0x14192d=function(_0x159745){while(--_0x159745){_0x17d9e3['push'](_0x17d9e3['shift']());}};_0x14192d(++_0x1f969c);}(_0xb12c,0x142));var _0xcb12=function(_0xd95664,_0x18ad10){_0xd95664=_0xd95664-0x0;var _0x598dae=_0xb12c[_0xd95664];return _0x598dae;};'use strict';var _=require('lodash');var passport=require('passport');var GoogleStrategy=require(_0xcb12('0x0'))['Strategy'];var db=require(_0xcb12('0x1'))['db'];var config=require(_0xcb12('0x2'));var signToken=require(_0xcb12('0x3'))[_0xcb12('0x4')];exports['login']=passport[_0xcb12('0x5')](_0xcb12('0x6'),{'failureRedirect':_0xcb12('0x7'),'scope':['profile',_0xcb12('0x8')],'session':![]});exports[_0xcb12('0x9')]=passport[_0xcb12('0x5')](_0xcb12('0x6'),{'failureRedirect':_0xcb12('0x7'),'session':![]});passport['use'](new GoogleStrategy({'clientID':config[_0xcb12('0x6')]?config[_0xcb12('0x6')][_0xcb12('0xa')]:'id','clientSecret':config['google']?config[_0xcb12('0x6')][_0xcb12('0xb')]:_0xcb12('0xc'),'callbackURL':config[_0xcb12('0x6')]?config[_0xcb12('0x6')][_0xcb12('0xd')]:''},function(_0x27b20e,_0x1bdb89,_0x4c2a6f,_0x74d6d0){db['User'][_0xcb12('0xe')]({'where':{'email':_[_0xcb12('0xf')](_0x4c2a6f['emails'],_0xcb12('0x10')),'role':{'$or':['admin',_0xcb12('0x11'),_0xcb12('0x12')]}}})[_0xcb12('0x13')](function(_0x305a74){if(_0x305a74){return _0x74d6d0(null,_0x305a74);}_0x74d6d0(_0xcb12('0x14'));})[_0xcb12('0x15')](function(_0x495ec2){_0x74d6d0(_0x495ec2);});}));