Example #1
0
 public function __construct()
 {
     if (!\Auth::user()->cluster) {
         throw new SoapException("You have no Active Cluster Selected");
     }
     $this->cluster = \Auth::user()->cluster;
     parent::__construct(storage_path() . '/app/sxml/RISAPI.wsdl', ['trace' => true, 'exceptions' => true, 'location' => 'https://' . $this->cluster->ip . ':8443/realtimeservice/services/RisPort', 'login' => $this->cluster->username, 'password' => $this->cluster->password, 'stream_context' => $this->cluster->verify_peer ?: stream_context_create(array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false)))]);
 }
Example #2
0
 /**
  *
  */
 public function __construct()
 {
     if (!\Auth::user()->cluster) {
         throw new SoapException("You have no Active Cluster Selected");
     }
     $this->cluster = \Auth::user()->cluster;
     parent::__construct('https://' . $this->cluster->ip . '/controlcenterservice2/services/ControlCenterServices?wsdl', ['trace' => true, 'exceptions' => true, 'location' => 'https://' . $this->cluster->ip . ':8443/controlcenterservice2/services/ControlCenterServices', 'login' => $this->cluster->username, 'password' => $this->cluster->password, 'stream_context' => $this->cluster->verify_peer ?: stream_context_create(array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false)))]);
 }
Example #3
0
 public function observationReward()
 {
     $mission = Mission::with('type')->find(\Request::get('mission_id'));
     if ($mission->type->name == 'location') {
         return $this->locationReward(\Auth::user()->id, $mission->id);
     } else {
         return $this->routeReward(\Auth::user()->id, $mission->id);
     }
 }
Example #4
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     $role = $data['role'];
     if ($role == 'admin' && !Auth::user()->isAdmin()) {
         $role = 'person';
     }
     $user = User::create(['nickname' => $data['nickname'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'role' => $role]);
     Person::create(['user_id' => $user->id, 'first_name' => $data['first_name'], 'last_name' => $data['last_name']]);
     return $user;
 }
Example #5
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next)
 {
     $user = AuthService::getUser();
     if (!$user->isLogin) {
         $newResponse = $response->withStatus(302)->withHeader('Location', '/auth/login');
         return $newResponse;
     }
     $response = $next($request, $response);
     return $response;
 }
Example #6
0
 /**
  * @param $phoneIP
  * @throws SoapException
  */
 function __construct($phoneIP)
 {
     if (!\Auth::user()->cluster) {
         throw new SoapException("You have no Active Cluster Selected");
     }
     $this->phoneIP = $phoneIP;
     $this->cluster = \Auth::user()->cluster;
     $this->client = new Client(['base_uri' => 'http://' . $this->phoneIP, 'verify' => false, 'connect_timeout' => 2, 'headers' => ['Accept' => 'application/xml', 'Content-Type' => 'application/xml'], 'auth' => [$this->cluster->username, $this->cluster->password]]);
     $this->reader = new Reader();
 }
Example #7
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next)
 {
     //$response->getBody()->write('BEFORE');
     $user = AuthService::getUser();
     if ($user->isLogin) {
         // @TODO  login action
     }
     $response = $next($request, $response);
     //$response->getBody()->write('AFTER');
     return $response;
 }
Example #8
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next)
 {
     //$response->getBody()->write('BEFORE');
     $user = AuthService::getUser();
     if (!$user->isLogin) {
         // @TODO no login action
         $response->getBody()->write('Access Denied');
         // $next = 'App\Controllers\HomeController:home';
         return $response;
     }
     $response = $next($request, $response);
     //$response->getBody()->write('AFTER');
     return $response;
 }
Example #9
0
 public static function getSmarty()
 {
     $smarty = new smarty();
     //实例化smarty
     $smarty->settemplatedir(BASE_PATH . '/resources/views/' . Config::get('theme') . '/');
     //设置模板文件存放目录
     $smarty->setcompiledir(BASE_PATH . '/storage/framework/smarty/compile/');
     //设置生成文件存放目录
     $smarty->setcachedir(BASE_PATH . '/storage/framework/smarty/cache/');
     //设置缓存文件存放目录
     // add config
     $smarty->assign('config', Config::getPublicConfig());
     $smarty->assign('user', Auth::getUser());
     return $smarty;
 }
Example #10
0
 public function doCheckin($request, $response, $args)
 {
     $user = Auth::getUser();
     //权限检查
     if (!$user->isAbleToCheckin()) {
         $tranferToAdd = 0;
         $res['msg'] = "签到过了哦";
         return $response->getBody()->write(json_encode($res));
     }
     $tranferToAdd = rand(Config::get('checkinMin'), Config::get('checkinMax'));
     // Add transfer
     $user->addTraffic($tranferToAdd);
     $res['msg'] = "获得了" . $tranferToAdd . "MB流量";
     return $response->getBody()->write(json_encode($res));
 }
 public function store()
 {
     //TODO: maybe the name of the device is not needed -> retrieve it from jwt
     $responseObs = $this->validateObservation();
     if ($responseObs->status == 'error') {
         return $responseObs;
     } else {
         $device = Device::where('device_uuid', \Request::get('device_uuid'))->first();
         //first check if the device is registered for this mission to radical
         //for our db, that means that there's a row in devices_missions table
         if (!$this->deviceService->isRegistered(\Request::get('mission_id'), \Request::get('device_uuid'))) {
             if ($this->mission == null) {
                 $this->mission = Mission::find(\Request::get('mission_id'));
             }
             if (!\Request::has('latitude') || \Request::get('latitude') == '') {
                 $latitude = number_format(0, 6);
             } else {
                 $latitude = number_format(\Request::get('latitude'), 6);
             }
             if (!\Request::has('longitude') || \Request::get('longitude') == '') {
                 $longitude = number_format(0, 6);
             } else {
                 $longitude = number_format(\Request::get('longitude'), 6);
             }
             //first create a row in devices_missions table
             $device->missions()->attach($this->mission->id, ['device_uuid' => env('RADICAL_CITYNAME') . '.' . $this->mission->radical_service_id . '.' . $device->device_uuid, 'latitude' => $latitude, 'longitude' => $longitude, 'registration_date' => date('Y-m-d H:i:s')]);
             $this->mission->users()->attach(\Auth::user()->id);
             //then send data to radical api
             $tmp_device = ['Device_UUID' => env('RADICAL_CITYNAME') . '.' . $this->mission->radical_service_id . '.' . $device->device_uuid, 'Model' => $device->model, 'Manufacturer' => $device->manufacturer, 'Latitude' => $latitude, 'Longitude' => $longitude, 'Type' => $device->type, 'Status' => intval($device->status), 'Registration_Date' => date('Y-m-d H:i:s')];
             $this->deviceService->registerToRadical($tmp_device);
         }
         $responseMeas = $this->validateMeasurements(\Request::get('measurements'));
         if ($responseMeas->status == 'error') {
             return \Response::json($responseMeas);
         }
         if ($this->mission == null) {
             $this->mission = Mission::find(\Request::get('mission_id'));
         }
         $observation = new Observation(['device_uuid' => env('RADICAL_CITYNAME') . '.' . $this->mission->radical_service_id . '.' . $device->device_uuid, 'latitude' => \Request::get('latitude'), 'longitude' => \Request::get('longitude'), 'observation_date' => \Request::get('observation_date'), 'device_id' => $device->id]);
         //save new observation to the db
         $observation->save();
         $radicalMeasurements = $this->getMeasurements($observation->id);
         $radicalObservation = ['Device_UUID' => env('RADICAL_CITYNAME') . '.' . $this->mission->radical_service_id . '.' . $device->device_uuid, 'Latitude' => \Request::get('latitude'), 'Longitude' => \Request::get('longitude'), 'Observation_Date' => \Request::get('observation_date'), 'Measurements' => $radicalMeasurements];
         $this->radicalIntegrationManager->storeObservation($radicalObservation);
         return $observation;
     }
 }
Example #12
0
 public function smarty()
 {
     global $config;
     $smarty = new smarty();
     //实例化smarty
     $smarty->settemplatedir(BASE_PATH . '/views/' . $config['theme'] . '/');
     //设置模板文件存放目录
     $smarty->setcompiledir(BASE_PATH . '/storage/framework/smarty/compile/');
     //设置生成文件存放目录
     $smarty->setcachedir(BASE_PATH . '/storage/framework/smarty/cache/');
     //设置缓存文件存放目录
     // add config
     $smarty->assign('config', $config);
     $smarty->assign('user', Auth::getUser());
     $this->smarty = $smarty;
     return $smarty;
 }
Example #13
0
 private function getLegalSessionArrayForDBInsert($request, $legalFolderId)
 {
     return array('legal_folder_id' => $legalFolderId, 'legal_date' => $this->datesHelper->makeDBFriendlyDate($request['legal_date']), 'legal_comments' => $request['legal_comments'], 'user_id' => \Auth::user()->id, 'medical_location_id' => $request['medical_location_id']);
 }
Example #14
0
 private function getPsychosocialSessionArrayForDBInsert($request, $socialFolderId)
 {
     $temp = $this->getPsychosocialSessionArrayForDBEdit($request);
     $temp['social_folder_id'] = $socialFolderId;
     $temp['psychologist_id'] = \Auth::user()->id;
     return $temp;
 }
Example #15
0
 public function show()
 {
     return View::make('view.setting')->withPoints(Auth::user()->point);
 }
Example #16
0
 public function selectOnlyReferrals($description, $referral_date, $benefiter_id, $referral_type_id)
 {
     $datesHelper = new DatesHelper();
     $referralDb = array('description' => $description, 'referral_date' => $datesHelper->makeDBFriendlyDate($referral_date), 'user_id' => \Auth::user()->id, 'benefiter_id' => $benefiter_id, 'referral_lookup_id' => $referral_type_id);
     return $referralDb;
 }
Example #17
0
 public function handleKill($request, $response, $args)
 {
     $user = Auth::getUser();
     $passwd = $request->getParam('passwd');
     // check passwd
     $res = array();
     if (!Hash::checkPassword($user->pass, $passwd)) {
         $res['ret'] = 0;
         $res['msg'] = " 密码错误";
         return $this->echoJson($response, $res);
     }
     Auth::logout();
     $user->delete();
     $res['ret'] = 1;
     $res['msg'] = "GG!您的帐号已经从我们的系统中删除.";
     return $this->echoJson($response, $res);
 }
Example #18
0
 public function logout($request, $response, $args)
 {
     Auth::logout();
     $newResponse = $response->withStatus(302)->withHeader('Location', '/auth/login');
     return $newResponse;
 }
 /**
  * @param $account
  * @param $data
  * @param $expenses
  * @param $vendorMap
  * @return mixed
  */
 private function parseTransactions($account, $data, $expenses, $vendorMap)
 {
     $ofxParser = new \OfxParser\Parser();
     $ofx = $ofxParser->loadFromString($data);
     $account->start_date = $ofx->BankAccount->Statement->startDate;
     $account->end_date = $ofx->BankAccount->Statement->endDate;
     $account->transactions = [];
     foreach ($ofx->BankAccount->Statement->transactions as $transaction) {
         // ensure transactions aren't imported as expenses twice
         if (isset($expenses[$transaction->uniqueId])) {
             continue;
         }
         if ($transaction->amount >= 0) {
             continue;
         }
         // if vendor has already been imported use current name
         $vendorName = trim(substr($transaction->name, 0, 20));
         $key = strtolower($vendorName);
         $vendor = isset($vendorMap[$key]) ? $vendorMap[$key] : null;
         $transaction->vendor = $vendor ? $vendor->name : $this->prepareValue($vendorName);
         $transaction->info = $this->prepareValue(substr($transaction->name, 20));
         $transaction->memo = $this->prepareValue($transaction->memo);
         $transaction->date = \Auth::user()->account->formatDate($transaction->date);
         $transaction->amount *= -1;
         $account->transactions[] = $transaction;
     }
     return $account;
 }
Example #20
0
 public function hashMatch($attribute, $value, $parameters)
 {
     return Hash::check($value, Auth::user()->{$parameters}[0]);
 }
Example #21
0
 public function addText()
 {
     $this->_methodName = 'addText';
     $this->resolveParams();
     $this->checkAuth();
     $arNeed = ['userTaskId' => 'required|numeric', 'text' => 'required'];
     $this->checkAttr($arNeed);
     $task_user = \App\UserTask::where('id', $this->_request_params['userTaskId'])->where('id_user', Auth::user()->id)->first();
     if (is_null($task_user)) {
         throw new \App\Exceptions\ExceptionApiContactnotfound($this->_request_params, $this->_typeName, $this->_methodName);
     }
     $infoTask = \App\InfoTask::where('id_taskUser', $task_user->id)->first();
     if (is_null($infoTask)) {
         $infoTask = new \App\InfoTask();
         $infoTask->id_taskUser = $task_user->id;
     }
     $infoTask->text = $this->_request_params['text'];
     $infoTask->save();
     return $this;
 }
Example #22
0
 /**
  * Remove book from wishlist.
  * @param  [type] $book_id [description]
  * @return [type]          [description]
  */
 public function removeBookFromWishlist($bookId)
 {
     $user_id = Auth::user()->id;
     DB::table('book_wishlist')->where('user_id', '=', $bookId)->where('book_id', '=', $book_id)->delete();
 }
 private function parseBankAccount($account, $bankAccounts, $expenses, $includeTransactions, $vendorMap)
 {
     $obj = new stdClass();
     $obj->account_name = '';
     // look up bank account name
     foreach ($bankAccounts as $bankAccount) {
         if (Hash::check($account->id, $bankAccount->account_number)) {
             $obj->account_name = $bankAccount->account_name;
         }
     }
     // if we can't find a match skip the account
     if (count($bankAccounts) && !$obj->account_name) {
         return false;
     }
     $obj->masked_account_number = Utils::maskAccountNumber($account->id);
     $obj->hashed_account_number = bcrypt($account->id);
     $obj->type = $account->type;
     $obj->balance = Utils::formatMoney($account->ledgerBalance, CURRENCY_DOLLAR);
     if ($includeTransactions) {
         $ofxParser = new \OfxParser\Parser();
         $ofx = $ofxParser->loadFromString($account->response);
         $obj->start_date = $ofx->BankAccount->Statement->startDate;
         $obj->end_date = $ofx->BankAccount->Statement->endDate;
         $obj->transactions = [];
         foreach ($ofx->BankAccount->Statement->transactions as $transaction) {
             // ensure transactions aren't imported as expenses twice
             if (isset($expenses[$transaction->uniqueId])) {
                 continue;
             }
             if ($transaction->amount >= 0) {
                 continue;
             }
             // if vendor has already been imported use current name
             $vendorName = trim(substr($transaction->name, 0, 20));
             $key = strtolower($vendorName);
             $vendor = isset($vendorMap[$key]) ? $vendorMap[$key] : null;
             $transaction->vendor = $vendor ? $vendor->name : $this->prepareValue($vendorName);
             $transaction->info = $this->prepareValue(substr($transaction->name, 20));
             $transaction->memo = $this->prepareValue($transaction->memo);
             $transaction->date = \Auth::user()->account->formatDate($transaction->date);
             $transaction->amount *= -1;
             $obj->transactions[] = $transaction;
         }
     }
     return $obj;
 }
Example #24
0
 public function logout()
 {
     Auth::logout();
 }
 /**
  * @return \Illuminate\Contracts\Auth\Guard
  */
 protected function getGuard()
 {
     return \Auth::guard($this->getGuardName());
 }
Example #26
0
 /**
  * @param $results
  * @return mixed
  */
 public function formatProductDataForAjax($results)
 {
     foreach ($results as &$item) {
         $item->urlProductDetail = urlProductDetail($item);
         $item->sell_price_show = formatMoney($item->sell_price);
         $item->discount_show = formatMoney($item->discount);
         $item->price_after_discount_show = formatMoney($item->sell_price - $item->discount);
         $item->style = $item->style->toArray();
         $item->is_loggin = \Auth::check() ? 1 : 0;
         if (count($item->properties)) {
             $item->properties_js = $item->properties;
         } else {
             $item->properties_js = 0;
         }
     }
     return $results->toArray();
 }
Example #27
0
 public function changePassword()
 {
     $this->_methodName = 'edit';
     $this->resolveParams();
     // TODO Сделать изменения для админов
     $this->checkAuth();
     if (!Auth::checkAdmin()) {
         $user = Auth::user();
         $arNeed = ['oldpasswd' => 'required|min:8|max:32', 'newpasswd' => 'required|min:8|max:32'];
         $this->checkAttr($arNeed);
         if (Hash::check($this->_request_params['oldpasswd'], $user->password)) {
             $user->password = Hash::make(strip_tags(trim($this->_request_params['newpasswd'])));
             $user->save();
             return $this;
         } else {
             throw new \App\Exceptions\ExceptionApiAuthCodeinactive(['token' => $this->_request_params['token']], $this->_typeName, $this->_methodName);
         }
     } else {
         return $this;
     }
 }
Example #28
0
        return redirect('/');
    }
});
Route::get('/setting', function () {
    Auth::login();
    if (Auth::checkAdmin()) {
        $controller = new \App\Http\Controllers\ControllerSetting();
        return $controller->init();
    } else {
        return redirect('/');
    }
});
Route::any('/api/{model?}.{method?}', function ($model = null, $method = null) {
    $controller = 'App\\Http\\Controllers\\Api\\ControllerApi' . ucfirst($model);
    try {
        App\Services\Auth::login();
        if (class_exists($controller)) {
            if (!method_exists($controller, $method)) {
                throw new \App\Exceptions\ExceptionApiMethodbad($model, $method, Request::all());
            }
            $ob = new $controller();
            $reflection = new ReflectionMethod($ob, $method);
            if (!$reflection->isPublic()) {
                throw new \App\Exceptions\ExceptionApiMethodbad($model, $method, Request::all());
            }
        } else {
            throw new \App\Exceptions\ExceptionApiTypebad($model, $method, Request::all());
        }
        if (!$ob instanceof App\Http\Controllers\Api\ControllerApi) {
            throw new \App\Exceptions\ExceptionApiTypebad($model, $method, Request::all());
        }
Example #29
0
 public function logout($request, $response, $args)
 {
     Auth::logout();
     return $this->redirect($response, '/auth/login');
 }
Example #30
0
 protected function checkUserUnable()
 {
     $validator = Validator::make(Auth::user()->toArray(), ['first_name' => 'required|max:32', 'last_name' => 'required|max:32', 'street' => 'required|max:128', 'occupation' => 'required|max:64', 'city' => 'required|max:64']);
     $mes = $validator->messages();
     //dd($mes);
     if ($validator->fails()) {
         return false;
     }
     return true;
 }