当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth::attempt方法代码示例

本文整理汇总了PHP中App\Http\Controllers\Auth\Auth::attempt方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::attempt方法的具体用法?PHP Auth::attempt怎么用?PHP Auth::attempt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Http\Controllers\Auth\Auth的用法示例。


在下文中一共展示了Auth::attempt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 public function login()
 {
     //echo "Came to validation part>>>!";
     if (Auth::attempt(array('email' => Input::json('email'), 'password' => Input::json('password')))) {
         return Response::json(Auth::user());
     } else {
         return Response::json(array('flash' => 'Invalid username or password'), 500);
     }
 }
开发者ID:udayrockstar,项目名称:phonebook,代码行数:9,代码来源:AuthController.php

示例2: postLogin

 public function postLogin()
 {
     // Формируем базовый набор данных для авторизации
     // (isActive => 1 нужно для того, чтобы авторизоваться могли только
     // активированные пользователи)
     $creds = array('password' => Input::get('password'), 'isActive' => 1);
     // В зависимости от того, что пользователь указал в поле username,
     // дополняем авторизационные данные
     $username = Input::get('username');
     if (strpos($username, '@')) {
         $creds['email'] = $username;
     } else {
         $creds['username'] = $username;
     }
     // Пытаемся авторизовать пользователя
     if (Auth::attempt($creds, Input::has('remember'))) {
         Log::info("User [{$username}] successfully logged in.");
         return Redirect::intended();
     } else {
         Log::info("User [{$username}] failed to login.");
     }
     $alert = "Неверная комбинация имени (email) и пароля, либо учетная запись еще не активирована.";
     // Возвращаем пользователя назад на форму входа с временной сессионной
     // переменной alert (withAlert)
     return Redirect::back()->withAlert($alert);
 }
开发者ID:Aglok,项目名称:upbrain,代码行数:26,代码来源:UsersController.php

示例3: postLogin

 public function postLogin(\App\Http\Requests\LoginUserRequest $request)
 {
     if (\Auth::attempt($request->except('_token'), true)) {
         return redirect()->intended('/');
     }
     return back()->withInput()->with(['message' => 'Wrong email or password']);
 }
开发者ID:gultaj,项目名称:toster,代码行数:7,代码来源:AuthController.php

示例4: authenticate

 public function authenticate () 
 {
   if (Auth::attempt(['mobile' => $mobile, 'password' => $password])) 
   {
     return redirect()->intended('home');
   }
 }
开发者ID:kukujiabo,项目名称:linpai,代码行数:7,代码来源:AuthController.php

示例5: authenticate

 public function authenticate(Request $request)
 {
     if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
         // Authentication passed...
         return redirect()->intended('/');
     }
 }
开发者ID:fakharkhan,项目名称:mis,代码行数:7,代码来源:AuthController.php

示例6: authenticate

 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function authenticate()
 {
     if (Auth::attempt(['username' => $email, 'password' => $password, 'is_enabled' => 1])) {
         // Authentication passed...
         return redirect()->intended('home');
     }
 }
开发者ID:carriercomm,项目名称:kbsys,代码行数:12,代码来源:AuthController.php

示例7: authenticate

 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function authenticate()
 {
     if (Auth::attempt(['usr_email' => $email, 'usr_password' => $password])) {
         // Authentication passed...
         return redirect()->intended('helloworld');
     }
 }
开发者ID:jsabbath,项目名称:6da8ddfe23f557d513c3516401d833ad723e940e279b88f7e4df24f4cbe4fc9fabeca495efc32408415475dc5de307a3bbc5,代码行数:12,代码来源:AuthController.php

示例8: postLogin

 /**
  * Handle a login request to the application.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function postLogin(\Illuminate\Http\Request $request)
 {
     if (\App::environment('local')) {
         $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     } else {
         $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required', 'g-recaptcha-response' => 'required|recaptcha']);
     }
     // If the class is using the ThrottlesLogins trait, we can automatically throttle
     // the login attempts for this application. We'll key this by the username and
     // the IP address of the client making these requests into this application.
     $throttles = $this->isUsingThrottlesLoginsTrait();
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $credentials = $this->getCredentials($request);
     if (\Auth::attempt($credentials, $request->has('remember'))) {
         return $this->handleUserWasAuthenticated($request, $throttles);
     }
     // If the login attempt was unsuccessful we will increment the number of attempts
     // to login and redirect the user back to the login form. Of course, when this
     // user surpasses their maximum number of attempts they will get locked out.
     if ($throttles) {
         $this->incrementLoginAttempts($request);
     }
     return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
 }
开发者ID:amirmasoud,项目名称:chakoshLaravelBlog,代码行数:33,代码来源:AuthController.php

示例9: loginUser

 protected function loginUser(Request $request)
 {
     $email = $request['email'];
     $password = $request['password'];
     if (\Auth::attempt(['email' => $email, 'password' => $password])) {
         return redirect('/dashboard');
     }
 }
开发者ID:vthakur96,项目名称:teamer,代码行数:8,代码来源:AuthController.php

示例10: authenticate

 /**
  * Create a new authentication controller instance.
  *
  * @return void
  */
 public function authenticate()
 {
     $remember = Input::has('remember') ? true : false;
     if (Auth::attempt(['email' => $email, 'password' => $password], $remember)) {
         return redirect()->intended('dashboard');
     } else {
         return Redirect::to('/login')->withInput(Input::except('password'))->with('flash_notice', 'Your username/password combination was incorrect.');
     }
 }
开发者ID:joannamroz,项目名称:dietary,代码行数:14,代码来源:AuthController.php

示例11: login

 protected function login(LoginRequest $request)
 {
     $credentials = $request->only('email', 'password');
     if (Auth::attempt($credentials)) {
         return 'Success';
     } else {
         return 'Failed';
     }
 }
开发者ID:jenrielzany,项目名称:green-tracker,代码行数:9,代码来源:AuthController.php

示例12: postIndex

 public function postIndex(Request $req)
 {
     $username = \Auth::user()->username;
     if (\Auth::attempt(['username' => $username, 'password' => $req->password])) {
         $req->session()->forget('lock');
         return redirect('/');
     }
     return redirect()->back()->withErr('* Kata sandi tidak cocok!');
 }
开发者ID:pedangkayu,项目名称:rsos-git,代码行数:9,代码来源:LockScreenController.php

示例13: postLogin

 public function postLogin(Request $request)
 {
     $username = $request->input('username');
     $password = $request->input('password');
     if (\Auth::attempt(['username' => $username, 'password' => $password])) {
         $this->userRepository->createLog(Carbon\Carbon::now());
         return redirect('/');
     }
     return redirect('/login')->withErrors('Invalid Username or Password.');
 }
开发者ID:crow1796,项目名称:technologyRIS,代码行数:10,代码来源:TrisAuthController.php

示例14: login

 public function login(Request $request)
 {
     $data = Input::only('username', 'password');
     $credentials = ['username' => $data['username'], 'password' => $data['password']];
     if (\Auth::attempt($credentials)) {
         //dd(\Auth::user());
         return response()->json(["success" => true], 200);
     }
     return response()->json(["success" => false], 401);
 }
开发者ID:iramgutierrez,项目名称:simple-cms-laravel-angularjs,代码行数:10,代码来源:AuthController.php

示例15: authenticate

 public function authenticate()
 {
     // $decrypt_pass = Crypt::decrypt($password);
     // if (Auth::attempt(['username' => $username, 'password' => $decrypt_pass])) {
     //     return redirect()->intended('dashboard');
     // }
     if (Auth::attempt(['username' => $username, 'password' => $password])) {
         return redirect()->intended('dashboard');
     }
 }
开发者ID:nicegal17,项目名称:Accounting-System,代码行数:10,代码来源:AuthController.php


注:本文中的App\Http\Controllers\Auth\Auth::attempt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。