Built motion from commit (unavailable).|2.2.3
[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 _0x6af5=['google','/login','profile','email','callback','use','clientID','clientSecret','callbackURL','User','map','emails','value','admin','user','agent','then','User\x20email\x20not\x20found!','catch','passport','passport-google-oauth20','../../config/environment','../../components/auth/service','signToken','login','authenticate'];(function(_0x1d61b5,_0x27993b){var _0xe435c2=function(_0x2ab19b){while(--_0x2ab19b){_0x1d61b5['push'](_0x1d61b5['shift']());}};_0xe435c2(++_0x27993b);}(_0x6af5,0x7b));var _0x56af=function(_0x413feb,_0x10477f){_0x413feb=_0x413feb-0x0;var _0x40ee88=_0x6af5[_0x413feb];return _0x40ee88;};'use strict';var _=require('lodash');var passport=require(_0x56af('0x0'));var GoogleStrategy=require(_0x56af('0x1'))['Strategy'];var db=require('../../mysqldb')['db'];var config=require(_0x56af('0x2'));var signToken=require(_0x56af('0x3'))[_0x56af('0x4')];exports[_0x56af('0x5')]=passport[_0x56af('0x6')](_0x56af('0x7'),{'failureRedirect':_0x56af('0x8'),'scope':[_0x56af('0x9'),_0x56af('0xa')],'session':![]});exports[_0x56af('0xb')]=passport[_0x56af('0x6')](_0x56af('0x7'),{'failureRedirect':'/login','session':![]});passport[_0x56af('0xc')](new GoogleStrategy({'clientID':config[_0x56af('0x7')]?config[_0x56af('0x7')][_0x56af('0xd')]:'id','clientSecret':config[_0x56af('0x7')]?config['google'][_0x56af('0xe')]:'secret','callbackURL':config[_0x56af('0x7')]?config[_0x56af('0x7')][_0x56af('0xf')]:''},function(_0xbd31d5,_0x2ed73b,_0x2efb0d,_0xf0671f){db[_0x56af('0x10')]['find']({'where':{'email':_[_0x56af('0x11')](_0x2efb0d[_0x56af('0x12')],_0x56af('0x13')),'role':{'$or':[_0x56af('0x14'),_0x56af('0x15'),_0x56af('0x16')]}}})[_0x56af('0x17')](function(_0x54927c){if(_0x54927c){return _0xf0671f(null,_0x54927c);}_0xf0671f(_0x56af('0x18'));})[_0x56af('0x19')](function(_0x12473a){_0xf0671f(_0x12473a);});}));