本文整理汇总了PHP中Illuminate\Support\Facades\Auth::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::validate方法的具体用法?PHP Auth::validate怎么用?PHP Auth::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Auth
的用法示例。
在下文中一共展示了Auth::validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* @param $credentials
* @throws ValidationFailed
*/
public function validate($credentials)
{
$valid = Auth::validate($credentials);
if (!$valid) {
throw new ValidationFailed();
}
}
示例2: login
/**
* @return Redirect
*/
public function login()
{
$rules = array('email' => 'required', 'password' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return redirect('/')->withErrors($validator);
} else {
$user = array('email' => Input::get('email'), 'password' => Input::get('password'));
if (Auth::validate($user)) {
if (Auth::attempt($user)) {
// Grab Authenticated User's Data Once
$user_data = Auth::user();
Session::put('user_id', $user_data->id);
Session::put('name', $user_data->name);
Session::put('email_id', $user_data->email);
return redirect::to('settings');
}
} else {
/*Session::flash('message','Login Failed');
return redirect('auth/login');*/
return Redirect::back()->withInput()->withErrors('That Email/password does not exist.');
}
}
/* $email = Input::get('email');
$password = Input::get('password');
if (Auth::attempt(['email' => $email, 'password' => $password]))
{
return Redirect::intended('/settings/index');
}
return Redirect::back()
->withInput()
->withErrors('That Email/password combo does not exist.');*/
}
示例3: verifyByDocumentation
public function verifyByDocumentation($username, $password)
{
if (Auth::validate(['email' => $username, 'password' => $password])) {
$user = \App\User::where('email', $username)->first();
return $user->id;
} else {
return false;
}
}
示例4: verify
public function verify($username, $password)
{
$credentials = ['email' => $username, 'password' => $password];
$valid = Auth::validate($credentials);
if ($valid) {
return Auth::getProvider()->retrieveByCredentials($credentials)->id;
}
return false;
}
示例5: update_password
public function update_password($username, PasswordChangeRequest $request)
{
if (Auth::validate(['phone' => Auth::user()->phone, 'password' => $request->input('old_password')])) {
Auth::user()->password = bcrypt($request->input('password'));
Auth::user()->save();
return redirect()->back()->with('success', 'Password updated successfully');
} else {
return redirect()->back()->with('error', 'Current password do not match with one in our record!');
}
}
示例6: doLogin
public function doLogin()
{
// validate the info, create rules for the inputs
$rules = array('username' => 'required|min:5', 'password' => 'required|min:6');
// run the validation rules on the inputs from the form
$validator = Validator::make(Input::all(), $rules);
// if the validator fails, redirect back to the form
if ($validator->fails()) {
return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->withErrors($validator)->withInput(Input::except('password'));
// send back the input (not the password) so that we can repopulate the form
} else {
// create our user data for the authentication
$userdata = array('username' => Input::get('username'), 'password' => Input::get('password'));
// attempt to do the login
if (Auth::validate($userdata)) {
// Valid Login
$valid_login = true;
// Get User
$user = UserItem::findUser($userdata["username"]);
// Check if User Disabled
if (!$user->isEnabled()) {
return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.account_disabled"));
}
// Trigger Login Event & Validate
mergeEventFireResponse(true, Event::fire('user.login_validate', array($user, &$valid_login)));
// Check Valid
if ($valid_login) {
// Do Login
Auth::login($user);
// Add Login Log
LoginLogItem::addLog($user, true);
// Trigger Valid Login Event
Event::fire('user.valid_login', array($user));
// validation successful!
return Redirect::intended(URL::route(UserItem::dashboardRoute()))->with(FLASH_MSG_INFO, trans("auth-module::message.success_login"));
} else {
// Add Login Log
LoginLogItem::addLog($user, false);
// Trigger Invalid Login Event
Event::fire('user.invalid_login', array($userdata['username']));
// validation not successful, send back to form
return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.invalid_login"))->withInput(Input::except('password'));
}
} else {
// Add Login Log
LoginLogItem::addLogUsername($userdata["username"], false);
// Trigger Invalid Login Event
Event::fire('user.invalid_login', array(Input::get('username')));
// validation not successful, send back to form
return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.invalid_login"))->withInput(Input::except('password'));
}
}
}
示例7: verify
public function verify($username, $password)
{
$credentials = ['email' => $username, 'password' => $password];
if (Auth::validate($credentials)) {
$user = \CodeProject\Entities\User::where('email', $username)->first();
return $user->id;
}
/* if (Auth::once($credentials)) {
return Auth::user()->id;
}*/
return false;
}
示例8: postLogin
/**
* Logs the user in.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postLogin()
{
$loginData = Binput::only(['email', 'password']);
// Validate login credentials.
if (Auth::validate($loginData)) {
// Log the user in for one request.
Auth::once($loginData);
// We probably want to add support for "Remember me" here.
Auth::attempt($loginData);
return Redirect::intended('dashboard');
}
return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
}
示例9: postReset
/**
* Reset the current user's password.
* @return Redirect
*/
public function postReset()
{
$current_user = Auth::user();
if (!Auth::validate(array('username' => Auth::user()->username, 'password' => Input::get('current_password')))) {
return Redirect::back()->with('flash_error', 'Your current password does not match, please <a href="#password"> try again</a>!');
}
$validator = Validator::make(array('new_password' => Input::get('new_password'), 'new_password_confirmation' => Input::get('new_password_conf')), array('new_password' => 'required|min:5|confirmed'));
if ($validator->passes()) {
$current_user->password = Hash::make(Input::get('new_password'));
$current_user->save();
return Redirect::back()->with('flash_success', 'Your password has been updated successfully!');
}
return Redirect::back()->with('flash_error', 'Your new passwords do not match or your new password does not meet the minimum length five characters, please <a href="#password"> try again</a>!');
}
示例10: attemptToSignIn
/**
* @param array $data
* @param bool $rememberMe
* @param bool $login
*
* @return User|false
*/
public function attemptToSignIn(array $data, $rememberMe = false, $login = false)
{
if (!Auth::validate(array_only($data, ['email', 'password']))) {
Flash::error(trans('ahk_messages.credentials_mismatch'));
return false;
}
$user = $this->findByEmail($data['email']);
if (!$user->verified) {
Flash::error(trans('ahk_messages.please_validate_your_email_first'));
return false;
}
Auth::login($user);
return $user;
}
示例11: loginPost
/**
* Logs the user in.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function loginPost()
{
$loginData = Request::only(['login', 'password']);
// Login with username or email.
$loginKey = Str::contains($loginData['login'], '@') ? 'email' : 'username';
$loginData[$loginKey] = array_pull($loginData, 'login');
// Validate login credentials.
if (Auth::validate($loginData)) {
// Log the user in for one request.
Auth::once($loginData);
// We probably want to add support for "Remember me" here.
Auth::attempt($loginData);
//return Redirect::intended('/')
return Redirect::home()->withSuccess(trans('gitamin.signin.success'));
}
return Redirect::route('auth.login')->withInput(Request::except('password'))->withError(trans('gitamin.signin.invalid'));
}
示例12: changePassword
public function changePassword(Request $request)
{
$validator = Validator::make($request->all(), ['current_password' => 'required', 'password' => 'required|confirmed|min:6']);
if ($validator->fails()) {
return redirect('/admin/changePassword')->with('errors', $validator->errors()->all());
} else {
$user = Auth::user();
$credentials = ['email' => $user->email, 'password' => $request->get('current_password')];
$valid = Auth::validate($credentials);
if ($valid) {
$user->password = bcrypt($request->get('password'));
$user->save();
$request->session()->flash("notif", "Password successfully changed!");
return redirect('/profile');
}
return redirect('/admin/changePassword')->with('errors', ['Input correct current password']);
}
}
示例13: persist
/**
* Persist the changes.
*
* @param User $user
*
* @throws InvalidPasswordException
* @throws UnableToChangePasswordException
*
* @return bool
*/
public function persist(User $user)
{
$credentials['password'] = $this->input('current_password');
$credentials['email'] = $user->email;
if (!Auth::validate($credentials)) {
throw new InvalidPasswordException();
}
if ($user->from_ad) {
// If the user is from active directory, we won't
// allow them to change their password.
throw new UnableToChangePasswordException();
}
// Change the users password.
$user->password = $this->input('password');
if (!$user->save()) {
throw new UnableToChangePasswordException();
}
}
示例14: ChangePassword
public function ChangePassword(ChangePassRequest $request)
{
if (Auth::check()) {
$customer_data = ["email" => Auth::user()->email, "password" => $request->password_old];
/*kiem tra mat khau cu*/
if (Auth::validate($customer_data)) {
//dung mat khau
$customer = customer::find(Auth::user()->id);
$customer->password = Hash::make($request->password);
$customer->save();
Auth::logout();
return redirect()->route("login");
} else {
return redirect()->route("thongtin.template")->with("result", "Mật khẩu không chính xác");
}
} else {
return redirect()->route("login");
}
}
示例15: postLogin
/**
* Logs the user in.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postLogin()
{
$loginData = Binput::only(['email', 'password']);
// Validate login credentials.
if (Auth::validate($loginData)) {
// Log the user in for one request.
Auth::once($loginData);
// Do we have Two Factor Auth enabled?
if (Auth::user()->hasTwoFactor) {
// Temporarily store the user.
Session::put('2fa_id', Auth::user()->id);
return Redirect::route('auth.two-factor');
}
// We probably want to add support for "Remember me" here.
Auth::attempt($loginData);
return Redirect::intended('dashboard');
}
return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
}