本文整理汇总了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);
}
}
示例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);
}
示例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']);
}
示例4: authenticate
public function authenticate ()
{
if (Auth::attempt(['mobile' => $mobile, 'password' => $password]))
{
return redirect()->intended('home');
}
}
示例5: authenticate
public function authenticate(Request $request)
{
if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
// Authentication passed...
return redirect()->intended('/');
}
}
示例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');
}
}
示例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()]);
}
示例9: loginUser
protected function loginUser(Request $request)
{
$email = $request['email'];
$password = $request['password'];
if (\Auth::attempt(['email' => $email, 'password' => $password])) {
return redirect('/dashboard');
}
}
示例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.');
}
}
示例11: login
protected function login(LoginRequest $request)
{
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
return 'Success';
} else {
return 'Failed';
}
}
示例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!');
}
示例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.');
}
示例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);
}
示例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');
}
}