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


PHP Sentry::findUserByCredentials方法代码示例

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


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

示例1: post_login

 public function post_login()
 {
     $credentials = array('email' => Input::get('username'), 'password' => Input::get('password'));
     $remember = Input::has('remember') ? true : false;
     $rules = array('email' => array('required', 'min:2'), 'password' => array('required', 'min:6'));
     $messages = array('email.required' => 'È necessario specificare il proprio username e la propria password per accedere', 'email.min' => 'Lo username deve essere lungo almeno 2 caratteri', 'password.required' => 'È necessario specificare il proprio username e la propria password per accedere', 'password.min' => 'La password deve essere lunga almeno 6 caratteri');
     $validator = Validator::make($credentials, $rules, $messages);
     if ($validator->passes()) {
         try {
             $user = Sentry::findUserByCredentials($credentials);
             $groups = Group::all();
             if ($user) {
                 foreach ($groups as $group) {
                     if ($user->inGroup($group->name)) {
                         $userAuth = Sentry::authenticate($credentials, $remember);
                         if ($userAuth) {
                             return $this->make_response($credentials, false, array($user->first_name . ' ' . $user->first_last . ', Accesso ' . $group->name . ' consentito'), URL::to('admin/dashboard'));
                         }
                     }
                 }
             }
         } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
             return $this->make_response($credentials, true, array('Non hai inserito la password'));
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             return $this->make_response($credentials, true, array('Utente non trovato'));
         } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
             return $this->make_response($credentials, true, array('Password o nome utente non corretti'));
         } catch (\Exception $e) {
             return $this->make_response($credentials, true, array("errore non previsto: " . $e->getMessage()));
         }
     } else {
         $errors = $validator->messages;
         return $this->make_response($credentials, true, $errors);
     }
 }
开发者ID:lucabro81,项目名称:edutube,代码行数:35,代码来源:LoginController.php

示例2: postIndex

 /**
  * To edit member profile action
  * AccountController::postIndex()
  *
  * @return
  */
 public function postIndex()
 {
     $this->userService = new UserAccountService();
     $success_message = "";
     $user = CUtil::getAuthUser();
     $logged_user_id = $user->id;
     $input = \Input::all();
     $input['user_id'] = $logged_user_id;
     $input['email'] = $user['email'];
     if (\Input::has('edit_basic')) {
         $rules = array();
         $messages = array();
         if (\Input::has('new_email') && \Input::get('new_email') != $user['email']) {
             $rules['new_email'] = $this->userService->getValidatorRule('email');
         }
         if (\Input::get('password') != "" || \Input::get('password_confirmation') != "") {
             $rules['Oldpassword'] = 'Required';
         }
         if (\Input::has('Oldpassword') && \Input::has('password') && \Input::get('password') != "" && \Input::get('Oldpassword') != \Input::get('password')) {
             $rules['Oldpassword'] = $this->userService->getValidatorRule('Oldpassword');
             $messages['Oldpassword.is_valid_old_password'] = trans("myaccount/form.edit-profile.wrong_password");
             $rules['password'] = $this->userService->getValidatorRule('password');
             $rules['password_confirmation'] = 'Required|same:password';
         }
         $validator = \Validator::make(\Input::all(), $rules, $messages);
         if ($validator->fails()) {
             return \Redirect::back()->withInput()->withErrors($validator);
         } else {
             $credential = array('email' => \Sentry::getUser()->email, 'password' => \Input::get('Oldpassword'));
             try {
                 $user = \Sentry::findUserByCredentials($credential);
                 $success_message = $this->userService->updateBasicDetails($input);
             } catch (sentrycheck $e) {
                 return \Redirect::back()->withInput()->with('valid_user', \Lang::get('webshopauthenticate::myaccount/form.current_password'));
             }
         }
     } else {
         if (\Input::has('edit_personal')) {
             $rules = array();
             $rules['first_name'] = $this->userService->getValidatorRule('first_name');
             $rules['last_name'] = $this->userService->getValidatorRule('last_name');
             $messages = array();
             $validator = \Validator::make(\Input::all(), $rules, $messages);
             if ($validator->fails()) {
                 return \Redirect::back()->withInput()->withErrors($validator);
             }
             $this->userService->updateUserPersonalDetails($input);
             $success_message = \Lang::get('webshopauthenticate::myaccount/form.edit-profile.personal_details_update_sucess');
         }
     }
     return \Redirect::to(\Config::get('webshopauthenticate::uri') . '/myaccount')->with('success_message', $success_message);
 }
开发者ID:agriya,项目名称:webshopauthenticate,代码行数:58,代码来源:AccountController.php

示例3: doLogin

 public function doLogin()
 {
     try {
         $user = Sentry::findUserByCredentials(array('email' => isset($_POST['email']) ? $_POST['email'] : '', 'password' => isset($_POST['password']) ? $_POST['password'] : ''));
         $remember = isset($_POST['remember']) ? true : false;
         Sentry::login($user, $remember);
         if (Session::get('redirectUri', false) !== false) {
             return Redirect::to(Session::get('redirectUri'));
         } else {
             return Redirect::route('check.index');
         }
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         Session::flash('error', trans('user.login.no-email'));
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         Session::flash('error', trans('user.login.not-activated'));
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         Session::flash('error', trans('user.login.unknown'));
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         Session::flash('error', trans('user.login.suspended', $throttle->getSuspensionTime()));
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         Session::flash('error', trans('user.login.banned'));
     }
     return Redirect::back()->withInput();
 }
开发者ID:dbirchak,项目名称:ping,代码行数:24,代码来源:UserController.php

示例4: postChangePassword

 public function postChangePassword(&$messageArray)
 {
     $validate = Validator::make(Input::all(), User::$changePasswordRules, User::$changePasswordLangs);
     if ($validate->passes()) {
         $oldPassword = Input::get('oldPassword');
         $newPassword = Input::get('newPassword');
         try {
             $userData = Sentry::findUserByCredentials(array('username' => Sentry::getUser()->username, 'password' => $oldPassword));
             $userData->password = $newPassword;
             if ($userData->save()) {
                 $messageArray['status'] = TRUE;
                 $messageArray['message'] = "Đổi mật khẩu thành công";
             } else {
                 $messageArray['message'] = "Đã có lỗi xảy ra trong quá trình đổi mật khẩu. Bạn vui lòng thử lại sau";
             }
         } catch (\Cartalyst\Sentry\Users\WrongPasswordException $e) {
             $messageArray['message'] = "Mật khẩu không chính xác";
         }
     } else {
         $messageArray['validate'] = $validate->messages();
     }
 }
开发者ID:huycao,项目名称:yoplatform,代码行数:22,代码来源:UserAdminController.php

示例5: findUserByCredentials

 public function findUserByCredentials($array)
 {
     return Sentry::findUserByCredentials($array);
 }
开发者ID:doowebdev,项目名称:core,代码行数:4,代码来源:SentryRepository.php

示例6: postNewPassword

 /**
  * Change new password
  */
 public function postNewPassword($email, $key)
 {
     $valid = Validator::make(['email' => $email, 'key' => $key], ['email' => 'required|email|exists:users', 'key' => 'required|exists:users,reset_password_code']);
     if ($valid->fails()) {
         return Redirect::route('larauth.new_password', ['email' => $email, 'key' => $key])->with('errors', $valid->errors());
     }
     $valid = Validator::make(['password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation')], ['password' => 'required|confirmed|min:' . Config::get('larauth::registration.min_password')], ['key.required' => trans('larauth::larauth,process_key_required'), 'password.required' => trans('larauth::larauth.password_required'), 'password.confirmed' => trans('larauth::larauth.password_confirmed'), 'password.min' => trans('larauth::larauth.password_min', ['min' => Config::get('larauth::registration.min_password')])]);
     if ($valid->fails()) {
         return Redirect::route('larauth.new_password', ['email' => $email, 'key' => $key])->with('errors', $valid->errors());
     }
     $user = Sentry::findUserByCredentials(['email' => $email]);
     if ($user->attemptResetPassword($key, Input::get('password'))) {
         return Redirect::route('larauth.new_password')->with('processed', true);
     }
 }
开发者ID:bitw,项目名称:larauth,代码行数:18,代码来源:LarauthController.php


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