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


PHP Auth::attempt方法代码示例

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


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

示例1: postLogin

 /**
  * 动作:登录
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin(Request $request)
 {
     if (Auth::attempt(['username' => $request->input('username'), 'password' => $request->input('password')])) {
         return redirect()->back();
     }
     return redirect()->intended('auth/login');
 }
开发者ID:lanzhiwang,项目名称:laravel-blog,代码行数:13,代码来源:PostController.php

示例2: facebook

 public function facebook()
 {
     $fb = new Facebook\Facebook(['app_id' => '144053429274589', 'app_secret' => '4ef6916e238aff3b6726dac08b853135', 'default_graph_version' => 'v2.4', 'default_access_token' => 'CAACDBA17B90BAKI0aOXR1vF5zDtZCOKPbWSXopnvvNpBTHZARXVhUVrZBAXn4CB1ZBgsyk13ZA38uZAWoffwchukfajiIOG7cYrNEEAm0CdlHgwDRWeBuD0OZCfT6PB6U2vsE3O45jTgx0YTc24TXEqyZC1ZBIjc9GxD3aSv6WAyIWsZCpAcbnxYPNCdL389FxaRsZD']);
     try {
         $response = $fb->get('/me?fields=id,name,email');
     } catch (Facebook\Exceptions\FacebookResponseException $e) {
         echo 'Graph returned an error: ' . $e->getMessage();
         exit;
     } catch (Facebook\Exceptions\FacebookSDKException $e) {
         echo 'Facebook SDK returned an error: ' . $e->getMessage();
         exit;
     }
     $me = $response->getGraphUser();
     $name = $me['name'];
     $email = $me['email'];
     $u_name = preg_replace('/@.*$/', '', $me['email']);
     $user = new User();
     $user->name = $name;
     $user->type = 'general';
     $user->register_type = 'facebook';
     $user->username = $u_name;
     $user->email = $email;
     $user->password = bcrypt($u_name);
     $user->save();
     $lastInsertedId = $user->id;
     $profile = new Profile();
     $profile = $user->profile()->save($profile);
     $credentials = array('email' => $email, 'password' => $u_name);
     if (Auth::attempt($credentials)) {
         //return Redirect::to('home');
         return redirect()->intended('home');
     }
     //echo '<pre>'; print_r($new_name);
     //echo 'Logged in as ' . $me['email'];
 }
开发者ID:udayc,项目名称:travel,代码行数:35,代码来源:AccountController.php

示例3: doLogin

 public function doLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:3');
     // 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::to('login')->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('email' => Input::get('email'), 'password' => Input::get('password'));
         // attempt to do the login
         if (Auth::attempt($userdata)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             echo 'SUCCESS!';
         } else {
             // validation not successful, send back to form
             return Redirect::to('login');
         }
     }
 }
开发者ID:arunsahoo,项目名称:CRUD-App,代码行数:26,代码来源:HomeController.php

示例4: login

 public static function login()
 {
     $ajaxRequest = \Request::ajax() && \Request::get('getIgnore_isAjax') ? true : false;
     if (!empty($_POST) && $ajaxRequest) {
         try {
             $email = \Request::get('email');
             $password = \Request::get('password');
             if (\Auth::attempt(array('email' => $email, 'password' => $password))) {
                 $allowedUserRoles = config('gtcms.allowedUserRoles');
                 $user = \Auth::user();
                 $userRole = $user->role;
                 if (in_array($userRole, $allowedUserRoles)) {
                     $defaultModel = self::getDefaultModelForUser($user);
                     if ($defaultModel) {
                         return \Redirect::to("/admin/" . $defaultModel . "?getIgnore_loginRedirect=true&getIgnore_isAjax=true");
                     }
                 } else {
                     \Auth::logout();
                 }
             }
             $data = array('success' => false, 'message' => trans('gtcms.incorrectUsernameOrPassword'));
             return \Response::json($data);
         } catch (\Exception $e) {
             return AdminHelper::handleException($e, trans('gtcms.errorHasOccurred') . ". " . trans('gtcms.pleaseRefresh') . ".");
         }
     }
     return \View::make('gtcms.admin.templates.adminLogin')->with(array('active' => false));
 }
开发者ID:gtcrais,项目名称:gtcms,代码行数:28,代码来源:AdminController.php

示例5: postLogin

 public function postLogin(Request $request)
 {
     if (\Auth::attempt(['email' => $input('email'), 'password' => $input('password')])) {
         return Redirect::to('dadsadash');
     } else {
         return Redirect::to('/user/login')->withErrors();
     }
 }
开发者ID:jokuf,项目名称:erp-obt,代码行数:8,代码来源:UserController.php

示例6: login

 /**
  * Login
  *
  * @param  Request  $request
  * @return Response
  */
 public function login(Request $request)
 {
     if (\Auth::attempt(array('email' => $request->email, 'password' => $request->password))) {
         return redirect()->intended('/profile');
     } else {
         return \Redirect::back();
     }
 }
开发者ID:jmoreirafilho,项目名称:SharingTests,代码行数:14,代码来源:HomeController.php

示例7: authenticate

 /**
  * Authenticate user
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function authenticate(Request $request)
 {
     $this->validate($request, ['email' => 'required|email|max:255', 'password' => 'required|max:255']);
     if (\Auth::attempt($request->only(['email', 'password'], $request->get('remember')))) {
         return redirect('/');
     }
     return redirect('/login')->withInput($request->only('login'))->withErrors(['error' => 'The credentials you entered did not match our records. Try again?']);
 }
开发者ID:atudz,项目名称:snapneat,代码行数:13,代码来源:AuthController.php

示例8: login

 public function login()
 {
     if (\Auth::attempt(['email' => Input::get('email'), 'password' => Input::get('password')])) {
         return Response::json(\Auth::user());
     } else {
         return Response::json(['msg' => 'Invalid credentials!'], 500);
     }
 }
开发者ID:Dreamerpro,项目名称:thinkmerit.api,代码行数:8,代码来源:ManualAuthController.php

示例9: login

 public function login()
 {
     $credentials = ['username' => \Input::get('username'), 'password' => \Input::get('password')];
     if (\Auth::attempt($credentials)) {
         return \Redirect::action('BackendController@index');
     }
     return \Redirect::action('LoginController@index')->with('error', 'Failed to login, invalid credentials.');
 }
开发者ID:VertexDezign,项目名称:VertexDezign,代码行数:8,代码来源:LoginController.php

示例10: index

 public function index(Request $request)
 {
     if (!\Auth::attempt($request->input())) {
         return response()->json(['status' => 'failed'], 200);
     } else {
         return response()->json(['status' => 'succeed', 'token' => csrf_token()], 200);
     }
 }
开发者ID:ametsuramet,项目名称:lumen-api,代码行数:8,代码来源:loginController.php

示例11: loginPost

 /**
  * Login a user
  *
  * @return \Illuminate\Http\Response
  */
 public function loginPost(Request $request)
 {
     $user = \Auth::attempt($request->only('username', 'password'));
     if (!$user) {
         return redirect('auth/login')->with('error', 'Incorrect Username/Password combination');
     }
     return redirect('/');
 }
开发者ID:richardkeep,项目名称:Requisition,代码行数:13,代码来源:UserController.php

示例12: signin

 public function signin(Requests\UserLoginRequest $request)
 {
     if (\Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password'), 'is_confirmed' => 1])) {
         return redirect('/');
     }
     \Session::falsh('user_login_failed', '密码不正确或邮箱没验证');
     return redirect('user/login')->withInput();
 }
开发者ID:wildKids,项目名称:Community,代码行数:8,代码来源:UsersController.php

示例13: postLogin

 public function postLogin(Request $request)
 {
     if (\Auth::attempt(['email' => $request->input('email'), 'password' => $request->input('password'), 'verified' => true])) {
         session()->flash('message', 'logged In');
         return redirect()->intendent('/');
     }
     session()->flash('message', 'Try Out');
     return redirect()->back();
 }
开发者ID:nirajanpoudel,项目名称:hrms,代码行数:9,代码来源:RegisterController.php

示例14: postIndex

 public function postIndex()
 {
     $username = Input::get('username');
     $password = Input::get('password');
     if (Auth::attempt(['username' => $username, 'password' => $password])) {
         return Redirect::intended('/user');
     }
     return Redirect::back()->withInput()->withErrors('That username/password combo does not exists');
 }
开发者ID:zmerrychristmas,项目名称:useradmin,代码行数:9,代码来源:HomeController.php

示例15: authenticate

 public function authenticate()
 {
     $data = \Input::all();
     if (\Auth::attempt(['nick' => $data['login'], 'password' => $data['password']], true)) {
         return \Redirect::back();
     } else {
         return \Redirect::back();
     }
 }
开发者ID:VovikeMS,项目名称:darts,代码行数:9,代码来源:AuthController.php


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