Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / components / license / service.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 _0xf48d=['final','parse','use','then','count','format','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','User','user','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','aes-256-ctr','%s:%s:%s','update','base64','utf8'];(function(_0x2976de,_0x4c546d){var _0xecbf51=function(_0x234025){while(--_0x234025){_0x2976de['push'](_0x2976de['shift']());}};_0xecbf51(++_0x4c546d);}(_0xf48d,0x150));var _0xdf48=function(_0x110c3d,_0x12ee06){_0x110c3d=_0x110c3d-0x0;var _0x226d67=_0xf48d[_0x110c3d];return _0x226d67;};'use strict';var crypto=require(_0xdf48('0x0'));var util=require(_0xdf48('0x1'));var compose=require(_0xdf48('0x2'));var db=require(_0xdf48('0x3'))['db'];var config=require(_0xdf48('0x4'));function getValueFromLicense(_0x495017,_0x53c2a1){if(_0x495017&&_0x53c2a1){if(_0x53c2a1[_0xdf48('0x5')]&&_0x53c2a1[_0xdf48('0x6')]){var _0x59444f=_0x53c2a1[_0xdf48('0x5')];var _0x4d0662=_0x53c2a1['license'];var _0x37cd42=_0x59444f[_0xdf48('0x7')]('-')[0x4];var _0x4f7181=_0x59444f['split']('-')[0x0];var _0x2c05dd=crypto[_0xdf48('0x8')](_0xdf48('0x9'),util['format'](_0xdf48('0xa'),_0x37cd42,_0x59444f,_0x4f7181));var _0x5ff187=_0x2c05dd[_0xdf48('0xb')](_0x4d0662,_0xdf48('0xc'),_0xdf48('0xd'));_0x5ff187+=_0x2c05dd[_0xdf48('0xe')](_0xdf48('0xd'));var _0x43a78e=JSON[_0xdf48('0xf')](_0x5ff187);return _0x43a78e['hasOwnProperty'](_0x495017)?_0x43a78e[_0x495017]:null;}}return null;}function isLimit(_0x1db915,_0x1ec04c,_0x379994,_0x1514c1){var _0x58cfc4=_0x1ec04c;return compose()[_0xdf48('0x10')](function(_0x373e4a,_0x1cf921,_0x4cc180){return db['License']['findOne']({'where':{'id':0x1},'raw':!![]})[_0xdf48('0x11')](function(_0x6bf103){var _0x23519d=getValueFromLicense(_0x1db915,_0x6bf103);return _0x23519d?_0x23519d:_0x58cfc4;})[_0xdf48('0x11')](function(_0x291134){_0x58cfc4=_0x291134;return _0x379994[_0xdf48('0x12')](_0x1514c1);})[_0xdf48('0x11')](function(_0x16f73d){if(_0x16f73d>=_0x58cfc4){return _0x1cf921['status'](0x193)['json']({'message':util[_0xdf48('0x13')](_0xdf48('0x14'),_0x1db915)});}_0x4cc180();})[_0xdf48('0x15')](function(_0x448672){_0x4cc180(_0x448672);});});}function isUserLimit(){return isLimit('users',0x1,db[_0xdf48('0x16')],{'where':{'$or':[{'role':'admin'},{'role':_0xdf48('0x17')}]}});}exports[_0xdf48('0x18')]=isUserLimit;