本文整理汇总了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);
}
}
示例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);
}
示例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();
}
示例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();
}
}
示例5: findUserByCredentials
public function findUserByCredentials($array)
{
return Sentry::findUserByCredentials($array);
}
示例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);
}
}