Пример #1
0
 public function signInAuth(SignInRequest $request)
 {
     if ((new Authenticate($request->input('username'), $request->input('password')))->check()) {
         return redirect()->route('index');
     }
     return back()->withErrors(['formError' => 'Invalid username or password.']);
 }
Пример #2
0
 /**
  * @param SignInRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(SignInRequest $request)
 {
     $input = $request->only('email', 'password');
     if (!\Auth::attempt($input)) {
         Flash::message('Wrong credentials');
         return Redirect::back()->withInput();
     }
     Flash::message('Welcome Back!');
     return Redirect::intended('statuses');
 }
Пример #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(\App\Http\Requests\SignInRequest $request)
 {
     $credentials = $request->only('email', 'password');
     if (Auth::attempt($credentials, $request->has('remember'))) {
         flash()->success('Welcome Back!');
         return redirect()->intended(route('statuses_path'));
     }
     flash()->error('Invalid Credentials. We were unable to sign you in. Please check your credentials and try again!');
     return redirect()->route('login_path')->withInput();
 }
Пример #4
0
 public function attempt(SignInRequest $request)
 {
     $data['email'] = $request->get('email');
     $data['password'] = $request->get('password');
     if (Auth::attempt($data)) {
         $user = User::where('email', $data['email'])->first();
         Auth::login($user);
         return redirect('/list');
     }
     return redirect('/sign-in')->withErrors(['Login Failed. Make sure password and email are correct.']);
 }
Пример #5
0
 /**
  * 用户登录
  *
  * @param SignInRequest $request
  * @return \Illuminate\Http\JsonResponse
  * @throws \App\Exceptions\SignInException
  */
 public function doSignIn(SignInRequest $request)
 {
     $loginId = $request->get('login_id');
     $username = $request->get('username');
     $email = $request->get('email');
     $phone = $request->get('phone');
     $password = $request->get('password');
     $remember = $request->get('remember');
     if ($phone) {
         $user = UserManager::signInByPhone($phone, $password, $remember);
     } else {
         if ($email) {
             $user = UserManager::signInByEmail($email, $password, $remember);
         } else {
             if ($username) {
                 $user = UserManager::signInByUsername($username, $password, $remember);
             } else {
                 if (Tools::isEmail($loginId)) {
                     $user = UserManager::signInByEmail($loginId, $password, $remember);
                 } else {
                     if (Tools::isPhone($loginId)) {
                         $user = UserManager::signInByPhone($loginId, $password, $remember);
                     } else {
                         $user = UserManager::signInByUsername($loginId, $password, $remember);
                     }
                 }
             }
         }
     }
     return $this->buildResponse(trans('api.auth.sign_in.success'), Tools::toArray($user));
 }