本文整理汇总了PHP中Sentry::findUserByResetPasswordCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::findUserByResetPasswordCode方法的具体用法?PHP Sentry::findUserByResetPasswordCode怎么用?PHP Sentry::findUserByResetPasswordCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::findUserByResetPasswordCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cambioPw
public function cambioPw($codigo)
{
try {
$user = Sentry::findUserByResetPasswordCode($codigo);
// Check if the reset password code is valid
if ($user->checkResetPasswordCode($codigo)) {
$input = Input::all();
$reglas = array('password' => 'required|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()]);
}
// Attempt to reset the user password
if ($user->attemptResetPassword($codigo, Input::get('password'))) {
// Password reset passed
return Response::json(['success' => true]);
} else {
$error = array('error' => 'No es posible cambiar la contraseña');
return Response::json(['success' => false, 'error' => $error]);
}
} else {
$error = array('error' => 'El coóigo no es valido 1');
return Response::json(['success' => false, 'error' => $error]);
}
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
$error = 'El código no es valido';
return Response::json(['success' => false, 'error' => $error]);
}
// Find the user using the user id
}
示例2: resetPassword
public function resetPassword()
{
$token = Input::get('token', false);
$password = Input::get('password', false);
$password_confirmation = Input::get('password_confirmation', false);
if ($token && $password && $password_confirmation) {
if ($password === $password_confirmation) {
try {
$user = Sentry::findUserByResetPasswordCode($token);
if ($user->checkResetPasswordCode($token)) {
if ($user->attemptResetPassword($token, $password)) {
Sentry::login($user);
return Response::json([], 200);
} else {
return Response::json(['flash' => 'Password reset fail'], 400);
}
}
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
return Response::json(['flash' => 'No user has been found'], 400);
}
} else {
return Response::json(['flash' => 'Password and password confirmation must be the same'], 400);
}
}
return Response::json(['flash' => 'Field missing'], 400);
}
示例3: doUserRecover
public function doUserRecover($code)
{
$password = Input::get('new_password');
$confirmPassword = Input::get('new_password_confirm');
$validator = Validator::make(array('new_password' => $password, 'new_password_confirm' => $confirmPassword), array('new_password' => 'required|min:6|max:16', 'new_password_confirm' => 'required|min:6|max:16|same:new_password'));
if ($validator->fails()) {
$data = array('status' => false, 'errors' => $validator->messages()->all());
return Response::json($data);
}
$user = null;
try {
$user = Sentry::findUserByResetPasswordCode($code);
if ($user->attemptResetPassword($code, $password)) {
$data = array('status' => true, 'link' => URL::to('user/cabinet'));
} else {
$data = array('status' => false, 'errors' => array('Произошла ошибка во время установки нового пароля.'));
}
return Response::json($data);
} catch (UserNotFoundException $e) {
App::abort('404');
}
}
示例4: resetPassword
/**
* Resets user password.
*
* @param string $code
* @return Redirect
*/
public function resetPassword($code)
{
$new = str_random(20);
try {
$user = Sentry::findUserByResetPasswordCode(e($code));
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
return Redirect::to('/')->withFailure(trans('users.invalid reset code'));
}
if ($this->user->resetPassword($user, e($code), $new)) {
$data = array('username' => $user->username, 'email' => $user->email, 'password' => $new);
$this->user->sendNewPassword($data);
Event::fire('User.PasswordReset', array($user->username, Carbon::now()));
return Redirect::to('/')->withSuccess(trans('users.pass reset success'));
}
return Redirect::to('/')->withFailure(trans('users.pass reset failure'));
}
示例5: reset_form
/**
* Checks activation code for authenticity, then shows reset password form.
*
* @return Response
*/
public function reset_form($code = FALSE)
{
if ($code === FALSE) {
// Verification code is not present
Session::flash('alert_danger', 'Unable to reset password. Please use the link from the password reset email. If you are experiencing difficulty, please contact ACME.');
return Redirect::to('/login');
}
try {
$user = Sentry::findUserByResetPasswordCode($code);
// Check reset code was created < 1 hour ago
$code_hours_max = 1;
// Set max age in hours
$last_update = strtotime($user->updated_at);
$time_since_update = time() - $last_update;
// in seconds
$code_max_age = $code_hours_max * 60 * 60;
// in seconds
if ($time_since_update > $code_max_age) {
// Verification code is over 1 hour old
Session::flash('alert_danger', 'Expired verification code. Unable to reset password. Please try password recovery again.');
return Redirect::to('/login/recover');
} else {
// Show Password Reset Form
return View::make('public.reset_password', array('code' => $code, 'user_id' => $user->id));
}
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
// Verification code is not valid for any user
Session::flash('alert_danger', 'Invalid verification code. Unable to reset password. Please try password recovery again.');
return Redirect::to('/login/recover');
}
}
示例6: regresaUsuario
/**
* @SWG\Operation(
* partial="usuarios.show",
* summary="Muestra el usuario especificado",
* @SWG\Parameter(
* name="id",
* description="Identificador del usuario",
* required=true,
* type="integer",
* paramType="path",
* allowMultiple=false
* ),
* )
* @return Response
*/
public function regresaUsuario()
{
try {
$user = Sentry::findUserByResetPasswordCode(Input::get('codigo'));
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
echo 'User was not found.';
}
return $user;
}