本文整理汇总了PHP中Illuminate\Support\Facades\Password::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP Password::reset方法的具体用法?PHP Password::reset怎么用?PHP Password::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Password
的用法示例。
在下文中一共展示了Password::reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postReset
public function postReset(Request $request)
{
$params = $request->only('email', 'password', 'password_confirmation', 'token');
$filter = $this->validator($params);
if ($filter->fails()) {
// return $this->responseAnswer(true, NULL, trans('rest.14'), 14, $filter->errors());
return view('admin.reset')->with(['token' => $params['token'], 'message' => trans('auth.failed'), 'email' => $params['email'], 'error' => $filter->errors()->toArray()]);
}
$response = Password::reset($params, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
// $this->data = [
// 'authenticated' => true,
// 'role' => Auth::user()->isAdmin ? 'admin' : 'user',
// ];
// return $this->responseAnswer(false, $this->data, trans($response));
return redirect('/');
default:
// $this->data = [
// 'email' => $params['email'],
// 'token' => $params['token'],
// 'authenticated' => false,
// 'role' => 'guest',
// ];
// return $this->responseAnswer(true, NULL, trans($response), 1);
return view('admin.reset')->with(['token' => $params['token'], 'message' => $response, 'email' => $params['email']]);
}
}
示例2: postReset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postReset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
if ($response == Password::PASSWORD_RESET) {
return response()->json(["msg" => "Success", "data" => true], 200);
} else {
return response()->json(["msg" => "Unknown error", "data" => $response], 400);
}
}
示例3: postReset
/**
* Reset the given user's password.
*
* @param ResetPasswordRequest $request
* @return Response
*/
public function postReset(ResetPasswordRequest $request)
{
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect()->to('/')->with('ok', trans('passwords.reset'));
default:
return redirect()->back()->with('error', trans($response))->withInput($request->only('email'));
}
}
示例4: reset
/**
* @param ResetPasswordRequest $request
* @return $this|\Illuminate\Http\RedirectResponse
*/
public function reset(ResetPasswordRequest $request)
{
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect($this->redirectPath())->with('status', trans($response));
default:
return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
}
}
示例5: postReset
public function postReset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect()->route('auth.password_reminder.getEmail')->with('status', trans($response));
default:
return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
}
}
示例6: postReset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postReset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect(config('backend.backend.base_url') . '/dashboard');
default:
return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
}
}
示例7: postReset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postReset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect()->route('basecamp::login');
default:
abort(500, 'Invalid operation (User / Password / Token).');
}
}
示例8: postReset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postReset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return new JsonResponse([], 200);
default:
return new JsonResponse(['error' => trans($response)], 422);
}
}
示例9: postReset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postReset(Request $request)
{
$this->validate($request, ['token' => 'required', 'password' => 'required|confirmed|min:6|max:16']);
$credentials = $request->only('password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect()->back()->with('successReset', [1]);
default:
return redirect()->back()->withErrors(['token' => trans($response)]);
}
}
示例10: reset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function reset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect('login')->with('status', trans($response))->with('success', 'Your password has been reset, you can now log in.');
default:
return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)])->with('error', 'An error has occured, please try again.');
}
}
示例11: doReset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function doReset(ResetPasswordRequest $request)
{
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$user->password = bcrypt($password);
$user->save();
});
switch ($response) {
case Password::PASSWORD_RESET:
return $this->simpleArray(['message' => 'Se ha actualizado su contraseña.']);
default:
throw new ResourceException('No hemos podido restaurar su contraseña, verifique la información enviada.');
}
}
示例12: postReset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postReset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|min:8|confirmed'], ['email.required' => 'Sähköpostiosoite vaaditaan varmuuden vuoksi.', 'email.email' => 'Annettu sähköpostiosoite ei ole pätevä.', 'password.required' => 'Salasana puuttuu.', 'password.min' => 'Salasanan pitää olla vähintään :min merkkiä pitkä.', 'password.confirmed' => 'Salasanat eivät täsmää.']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect($this->redirectPath())->with('status', trans($response));
default:
return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
}
}
示例13: postReset
public function postReset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
/* customization: set 'flash_message' session var instead of 'status' */
return redirect($this->redirectPath())->with('flash_message', trans($response));
default:
return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
}
}
示例14: postReset
public function postReset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$credentials['department_id'] = $this->getDepartment()->id;
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect($this->redirectPath())->with('success', 'password-changed');
default:
return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
}
}
示例15: reset
/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function reset(Request $request)
{
$this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed']);
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$user->password = $password;
$user->save();
});
switch ($response) {
case Password::PASSWORD_RESET:
Session::flash('message', ['type' => 'success', 'content' => trans('user::account.change_password_success')]);
return redirect(route('auth.login'));
default:
return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response), 'msg' => trans($response)]);
}
}