當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。