本文整理汇总了PHP中Illuminate\Support\Facades\Password类的典型用法代码示例。如果您正苦于以下问题:PHP Password类的具体用法?PHP Password怎么用?PHP Password使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Password类的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: postEmail
/**
* Send a reset link to the given user.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postEmail(Request $request)
{
// $this->validate($request, ['email' => 'required|email', 'username' =>'required']);
/*
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
*/
$this->validate($request, ['email' => 'required|email', 'username' => 'required']);
$correo = DB::table('users')->where('username', '=', $request->username)->first();
if (is_null($correo)) {
$response = Password::INVALID_USER;
} else {
if ($correo->email == $request->email) {
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
} else {
$response = Password::INVALID_USER;
}
}
switch ($response) {
case Password::RESET_LINK_SENT:
session()->flash('flash_message', 'Se ha enviado un correo a la dirección de correo asociada.');
return view('auth.password');
case Password::INVALID_USER:
//session()->flash('flash_message_danger', 'No existe un usuario con ese nombre.');
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
示例3: postEmail
/**
* @param Request $request
* @throws GeneralException
* @return $this|\Illuminate\Http\RedirectResponse
*/
public function postEmail(Request $request)
{
/**
* First of all check if the input is a valid email
*/
$this->validate($request, ['email' => 'required|email']);
/**
* Make sure user is confirmed before resetting password.
*/
$user = User::where('email', $request->get('email'))->first();
if ($user) {
if ($user->confirmed == 0) {
throw new GeneralException('Your account is not confirmed. Please click the confirmation link in your e-mail, or ' . '<a href="' . route('account.confirm.resend', $user->id) . '">click here</a>' . ' to resend the confirmation e-mail.');
}
} else {
throw new GeneralException('There is no user with that e-mail address.');
}
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
case Password::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
示例4: reset_process
protected function reset_process($credentials)
{
return Password::user()->reset($credentials, function ($user, $password) {
$user->password = bcrypt($password);
$user->save();
Auth::user()->login($user);
});
}
示例5: postEmail
/**
* Send a reset link to the given user.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function postEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return redirect()->back()->with('status', 'Hemos enviando un link a tu cuenta de correo electrónico para que puedas resetear la contraseña');
case Password::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
示例6: postEmail
public function postEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email|max:255']);
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return redirect()->back()->with('message', trans($response))->with('loginTab', 'login');
case Password::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)])->with('loginTab', 'password');
}
}
示例7: 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'));
}
}
示例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);
});
if ($response == Password::PASSWORD_RESET) {
return response()->json(["msg" => "Success", "data" => true], 200);
} else {
return response()->json(["msg" => "Unknown error", "data" => $response], 400);
}
}
示例9: 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)]);
}
}
示例10: postEmail
public function postEmail(PasswordRequest $request)
{
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
Session::flash('message', 'Link de recuperación enviado por correo');
return redirect()->back()->with('status', trans($response));
case Password::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
示例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: postEmail
/**
* Send a reset link to the given user.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
Session::flash('flash_message', 'Reset Link was successfully sent to your email');
return redirect()->back()->with('status', trans($response));
case Password::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
示例13: 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).');
}
}
示例14: postEmail
/**
* Send a reset link to the given user.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
$message->from('smartads@domain.com', $name = 'Smart Ads');
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
case Password::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
示例15: 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)]);
}
}