当前位置: 首页>>代码示例>>PHP>>正文


PHP Sentry::findUserById方法代码示例

本文整理汇总了PHP中Sentry::findUserById方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::findUserById方法的具体用法?PHP Sentry::findUserById怎么用?PHP Sentry::findUserById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentry的用法示例。


在下文中一共展示了Sentry::findUserById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getList

 public function getList()
 {
     $albums = Album::with('Photos')->with('User')->get();
     echo var_export(\Sentry::findUserById(\Sentry::getUser()->id));
     exit;
     return View::make('index')->with('albums', $albums);
 }
开发者ID:deadlance,项目名称:laravel_project_test_2,代码行数:7,代码来源:AlbumsController.php

示例2: change

 public function change()
 {
     if (Request::isMethod('post')) {
         try {
             $rules = Validator::make(Input::all(), ['password' => 'required|confirmed', 'password_confirmation' => 'required']);
             if ($rules->fails()) {
                 throw new Exception('Todos los campos son obligatorios');
             }
             $data = explode('@', Input::get('data'));
             $id = base64_decode($data[1]);
             $user = Sentry::findUserById($id);
             $admin = Sentry::findGroupByName('Administrador');
             if (!$user->checkResetPasswordCode($data[0])) {
                 throw new Exception('El código de chequeo no es correcto.');
             }
             if (!$user->attemptResetPassword($data[0], Input::get('password_confirmation'))) {
                 throw new Exception('Se presento un error al guardar la nueva contraseña.');
             }
             if (!$user->inGroup($admin) || !$user->isActivated()) {
                 throw new Exception('Este usuario no tiene permisos para ingresar o esta inactivo.');
             }
             Sentry::login($user);
             return Redirect::route('admin.dashboard');
         } catch (Exception $e) {
             $uri = URL::route('admin.forgot-reset', [Input::get('data')]);
             return Redirect::to($uri)->with('message', $e->getMessage());
         }
     }
 }
开发者ID:eldalo,项目名称:jarvix,代码行数:29,代码来源:AdminController.php

示例3: loginByToken

 public function loginByToken($token = '')
 {
     if ($token) {
         $token = base64_decode($token);
         if (User::where('emf_token', '=', $token)->count()) {
             $user = User::where('emf_token', '=', $token)->first();
             if (is_null($user->last_login)) {
                 $start_page = 'walkthrough';
                 $maildata = new stdClass();
                 $maildata->user = $user->toArray();
                 Mail::later(8, 'emails.emf.welcome', (array) $maildata, function ($message) use($user) {
                     $message->to($user->email, $user->first_name && $user->last_name ? $user->first_name . ' ' . $user->last_name : null)->subject('Welcome!');
                 });
             } else {
                 $start_page = 'dashboard';
             }
             $sentry_user = Sentry::findUserById($user->id);
             Sentry::login($sentry_user, false);
             $user->password = md5(uniqid(mt_rand(), true));
             $user->emf_token = null;
             $user->updated_at = time();
             if ($user->save()) {
                 Log::info('loginByToken() User information was updated.');
             } else {
                 Log::info('loginByToken() User information was not updated!');
             }
             return Redirect::route($start_page, array('lang' => App::getLocale()));
         } else {
             return Redirect::route('login', array('lang' => App::getLocale()));
         }
     } else {
         return Redirect::route('login', array('lang' => App::getLocale()));
     }
 }
开发者ID:jinxiao8942,项目名称:laravel-kuu,代码行数:34,代码来源:EmfLoginController.php

示例4: postRegistro

 public function postRegistro()
 {
     $input = Input::all();
     $reglas = array('nombre' => 'required', 'apellido' => 'required', 'celular' => 'required|numeric|unique:users', 'cedula' => 'required|numeric|unique:users', 'email' => 'required|email|unique:users', 'pin' => 'required|numeric|digits_between:0,4', 'password' => 'required|numbers|case_diff|letters|min:6|confirmed', 'password_confirmation' => 'required|min:6');
     $validation = Validator::make($input, $reglas);
     if ($validation->fails()) {
         return Response::json(['success' => false, 'errors' => $validation->errors()->toArray()]);
     }
     try {
         // se guarda los datos del usuario
         $user = Sentry::register(array('first_name' => Input::get('nombre'), 'last_name' => Input::get('apellido'), 'email' => Input::get('email'), 'habilitar_pin' => 1, 'celular' => Input::get('celular'), 'cedula' => Input::get('cedula'), 'password' => Input::get('password'), 'pin' => Input::get('pin'), 'porcentaje' => 0.05, 'activated' => true));
         $userId = $user->getId();
         $token = new Token();
         $token->user_id = $userId;
         $token->api_token = hash('sha256', Str::random(10), false);
         $token->client = BrowserDetect::toString();
         $token->expires_on = Carbon::now()->addMonth()->toDateTimeString();
         $token->save();
         // Se autentica de una
         $user_login = Sentry::findUserById($userId);
         Sentry::login($user_login, false);
         return Response::json(['success' => true, 'user' => $user_login, 'token' => $token->api_token]);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $error = array('usuario' => 'Email es requerido');
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $error = array('usuario' => 'Password es requerido');
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         $error = array('usuario' => 'El Email ya está registrado');
     }
     return Response::json(['success' => false, 'errors' => $error]);
 }
开发者ID:riverajefer,项目名称:bcserver,代码行数:31,代码来源:AuthController.php

示例5: update_post

 public function update_post($id)
 {
     $this->_exists($id);
     $rules = User::get_rules($id);
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         // Find the user using the user id
         $user = Sentry::findUserById($id);
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->tin_number = Input::get('tin_number');
         $user->landline = Input::get('landline');
         $user->mobile = Input::get('mobile');
         $user->work_address = json_endcode(explode(",", Input::get('work_address')));
         $user->home_address = json_endcode(explode(",", Input::get('home_address')));
         $user->company = Input::get('company');
         $user->occupation = Input::get('occupation');
         $user->email = Input::get('email');
         if (Input::get('password')) {
             $user->password = Input::get('password');
         }
         if (Input::get('activated') == 1) {
             $user->activated = true;
         } else {
             $user->activated = false;
         }
         $user->save();
         return Redirect::to('admin/clients')->with('success', 'Client account has been successfully updated.');
     }
     return Redirect::to('admin/clients/update/' . $id)->withErrors($validator)->withInput();
 }
开发者ID:jacobDaeHyung,项目名称:Laravel-Real-Estate-Manager,代码行数:31,代码来源:ClientsController.php

示例6: pushMessage

 public function pushMessage()
 {
     if (!Sentry::check()) {
         return Response::json(array('errCode' => 10, 'message' => '请登录'));
     }
     Sentry::login(Sentry::findUserById(5), false);
     $user = Sentry::getUser();
     // $user = User::find(1);
     $push_status = PushStatus::where('user_id', $user->id)->first();
     if (count($push_status) == 0) {
         $push_status = new PushStatus();
         $push_status->user_id = $user->id;
         $push_status->status = 1;
         if (!$push_status->save()) {
             return Response::json(array('errCode' => 1, 'message' => '[数据库错误]开启消息推送失败'));
         }
         return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
     }
     if ($push_status->status == 1) {
         $push_status->status = 0;
         if (!$push_status->save()) {
             return Response::json(array('errCode' => 2, 'message' => '[数据库错误]开启消息推送失败'));
         }
         return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
     }
     if ($push_status->status == 0) {
         $push_status->status = 1;
         if (!$push_status->save()) {
             return Response::json(array('errCode' => 3, 'message' => '[数据库错误]开启消息推送失败'));
         }
         return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
     }
 }
开发者ID:Jv-Juven,项目名称:gift,代码行数:33,代码来源:SiteController.php

示例7: resetPassword

 public function resetPassword()
 {
     $input = Input::all();
     $user = User::where('email', '=', $input['email'])->first();
     $user = Sentry::findUserById($user->id);
     try {
         if ($user->checkResetPasswordCode($input['code'])) {
             if ($user->attemptResetPassword($input['code'], $input['password'])) {
                 $data = Citrus::response('data', 1);
                 $email = new UtilityMailman();
                 $email->setReceiver($user->email);
                 $email->setSubject('Successful Password Reset');
                 $body = $email->getBody('sreset', $user);
                 $email->setBody($body);
                 $data = $email->send($user);
             } else {
                 throw new Exception("Something is not right - please request another reset password link.");
             }
         } else {
             throw new Exception("Your reset code has expired. Please request another one.");
         }
     } catch (Exception $e) {
         $data = Citrus::response('error', $e);
     }
     return $data;
 }
开发者ID:hackGFS,项目名称:api,代码行数:26,代码来源:UserController.php

示例8: getGraphData

 public function getGraphData()
 {
     if (Sentry::getUser()) {
         $user_id = Sentry::getUser()->id;
         $period = Input::get('check_report_period');
         $mongo_id = Input::get('report_mongo_id');
         $check_id = Input::get('report_check_id');
         $mongoAPI = new MongoAPI();
         $checkAlertEmail = new CheckAlertEmail();
         $data = json_decode($mongoAPI->getServerModelData($mongo_id, $period), true);
         $data['alert'] = $checkAlertEmail->getDataByCheckId($check_id);
         return Response::json($data);
     } else {
         try {
             $user = Sentry::findUserById(Input::get('user_id'));
             $emf_group = Sentry::findGroupByName('EmfUsers');
             if ($user->inGroup($emf_group)) {
                 return $this->get_exired_message(Config::get('kuu.emf_login_page'));
             } else {
                 return $this->get_exired_message(URL::route('login'));
             }
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             return $this->get_exired_message(URL::route('login'));
         } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
             return $this->get_exired_message(URL::route('login'));
         }
     }
 }
开发者ID:jinxiao8942,项目名称:laravel-kuu,代码行数:28,代码来源:DashboardController.php

示例9: roles

 public static function roles($id_group, $id_user)
 {
     $user = Sentry::findUserById($id_user);
     foreach ($user->groups as $group) {
         if ($group->id == $id_group) {
             return true;
         }
     }
 }
开发者ID:hectorz11,项目名称:laravel_sistema_art,代码行数:9,代码来源:User.php

示例10: getUser

 public function getUser($id)
 {
     try {
         $user = Sentry::findUserById($id);
         return Response::json(array('user' => $user->toArray()));
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         echo 'User was not found.';
     }
 }
开发者ID:arizawan,项目名称:chaity.com,代码行数:9,代码来源:RainAuthController.php

示例11: destroy

 public function destroy($id)
 {
     try {
         // Find the user using the user id
         $user = Sentry::findUserById($id);
         // Delete the user
         $user->delete();
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         echo 'User was not found.';
     }
 }
开发者ID:kettanyam,项目名称:20141001done,代码行数:11,代码来源:UsersController.php

示例12: postUlogin

 public function postUlogin()
 {
     $_user = json_decode(file_get_contents('http://ulogin.ru/token.php?token=' . Input::get('token') . '&host=' . $_SERVER['HTTP_HOST']), true);
     //$user['network'] - соц. сеть, через которую авторизовался пользователь
     //$user['identity'] - уникальная строка определяющая конкретного пользователя соц. сети
     //$user['first_name'] - имя пользователя
     //$user['last_name'] - фамилия пользователя
     $validate = Validator::make([], []);
     if (isset($_user['error'])) {
         $validate->errors()->add('error', trans('larulogin::larulogin.' . $_user['error']));
         return Response::make(View::make(Config::get('larulogin::views.error'), ['errors' => $validate->errors()]), 401);
     }
     // Check exist user
     $check = Ulogin::where('identity', '=', $_user['identity'])->first();
     if ($check) {
         Auth::loginUsingId($check->user_id, true);
         if (class_exists('Sentry')) {
             $authSentry = Sentry::findUserById($check->user_id);
             Sentry::login($authSentry, true);
         }
         return Redirect::to('/');
     }
     $rules = array('network' => 'required|max:255', 'identity' => 'required|max:255|unique:ulogin', 'email' => 'required|unique:ulogin|unique:users');
     $messages = array('email.unique' => trans('larulogin::larulogin.email_already_registered'));
     $validate = Validator::make($_user, $rules, $messages);
     if ($validate->passes()) {
         $password = str_random(8);
         $user = Sentry::createUser(array('first_name' => $_user['first_name'], 'last_name' => $_user['last_name'], 'email' => $_user['email'], 'password' => $password, 'activated' => TRUE));
         foreach (Config::get('larulogin::add_to_groups') as $group_name) {
             $user->addGroup(Sentry::findGroupByName($group_name));
         }
         $ulogin = new Ulogin();
         $ulogin->user_id = $user->id;
         $ulogin->network = $_user['network'];
         $ulogin->identity = $_user['identity'];
         $ulogin->email = $_user['email'];
         $ulogin->first_name = $_user['first_name'];
         $ulogin->last_name = $_user['last_name'];
         $ulogin->photo = $_user['photo'];
         $ulogin->photo_big = $_user['photo_big'];
         $ulogin->profile = $_user['profile'];
         $ulogin->access_token = isset($_user['access_token']) ? $_user['access_token'] : '';
         $ulogin->country = isset($_user['country']) ? $_user['country'] : '';
         $ulogin->city = isset($_user['city']) ? $_user['city'] : '';
         $ulogin->save();
         $authClassic = Auth::loginUsingId($user->id);
         if (class_exists('Sentry')) {
             $authSentry = Sentry::authenticate(array('email' => $_user['email'], 'password' => $password), true);
         }
         return Redirect::to('/');
     } else {
         return Response::make(View::make(Config::get('larulogin::views.error'), array('errors' => $validate->errors())), 401);
     }
 }
开发者ID:bitw,项目名称:larulogin,代码行数:54,代码来源:LaruloginController.php

示例13: activate

 public function activate($activation_code, $id)
 {
     try {
         $user = \Sentry::findUserById($id);
         $user->attemptActivation($activation_code);
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $this->errors[] = trans('auth.user_not_found');
     } catch (\Cartalyst\Sentry\Users\UserAlreadyActivatedException $e) {
         $this->errors[] = trans('auth.user_already_activated');
     }
 }
开发者ID:justinf111,项目名称:laravel-blog,代码行数:11,代码来源:Auth.php

示例14: postPassClinic

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function postPassClinic()
 {
     $id = Input::get('pk');
     $pass = Input::get('value');
     $user = Sentry::findUserById($id);
     $user->password = $pass;
     if ($user->save()) {
         return 'ok';
     } else {
         return 'no';
     }
 }
开发者ID:jnicolasbc,项目名称:admin_swp_com,代码行数:17,代码来源:ClinicEditableController.php

示例15: editor

 /**
  * Get the media_entry's editor
  * @return string
  */
 public function editor()
 {
     if ($this->updated_by == null) {
         return '';
     }
     try {
         $user = Sentry::findUserById($this->updated_by);
         return $user->username;
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return '';
     }
 }
开发者ID:jrafaelca,项目名称:Doptor,代码行数:16,代码来源:MediaEntryPresenter.php


注:本文中的Sentry::findUserById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。