public function postLogin(LoginRequest $request) { if (!Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password')], true)) { session()->flash('errorMessages', ['You have entered an invalid email address or password.', 'Please try again.']); return back()->withInput(); } $user = Auth::user(); // if the user has a plant, set welcome message if (count($user->plants)) { $plant = $user->plants()->where('isHarvested', '=', false)->orderBy(DB::raw('RAND()'))->first(); if ($plant) { // set welcome message to need water or need fertilizer if the plant needs it $lastTimeWatered = $plant->getLastTimeWatered(); $lastTimeFertilized = $plant->getLastTimeFertilized(); $random = round(rand(1, 2)); if (!$lastTimeWatered && $plant->created_at->addDay() < Carbon::now()) { $status = $plant->plantCharacter['need_water_phrase_' . $random]; } elseif (!$lastTimeFertilized && $plant->created_at->addDay() < Carbon::now()) { $status = $plant->plantCharacter['need_fertilizer_phrase_' . $random]; } elseif ($lastTimeWatered && Carbon::createFromFormat('Y-m-d H:i:s', $lastTimeWatered->pivot->date)->addDay() < Carbon::now()) { $status = $plant->plantCharacter['need_water_phrase_' . $random]; } elseif ($lastTimeFertilized && Carbon::createFromFormat('Y-m-d H:i:s', $lastTimeFertilized->pivot->date)->addDay() < Carbon::now()) { $status = $plant->plantCharacter['need_fertilizer_phrase_' . $random]; } else { $status = $plant->plantCharacter['welcome_phrase_' . $random]; } session()->flash('message', $plant->plantCharacter->name . ': ' . $status); } } return redirect()->route('dashboard'); }
/** * Do Login * * @param LoginRequest $request * @return \Illuminate\Http\RedirectResponse */ public function postLogin(LoginRequest $request) { if (Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password')], $request->get('remember'))) { return redirect()->intended('/todo')->with('flash_notification.message', 'Logged in successfully')->with('flash_notification.level', 'success'); } return redirect()->back()->withInput()->with('flash_notification.message', 'Wrong email or password')->with('flash_notification.level', 'danger'); }
public function Login(LoginRequest $request) { $value = ["email" => $request->get("email"), "password" => $request->get("password")]; if ($request->remember_me == "1") { $remember = true; } else { $remember = false; } if ($this->auth->attempt($value, $remember)) { if ($request->get("email") == "*****@*****.**") { //admin return redirect()->route("admin.home"); } else { //customer $customer_id = $this->auth->user()->id; /* get list id of customer*/ $array_list_id = \App\LoveList::select(["id"])->where("customer_id", $customer_id)->get()->toArray(); /*del san pham */ $temp = \App\LoveListDetail::whereIn("list_id", $array_list_id)->count(); Session::put("love", $temp); //so luong san pham yeu thich return redirect()->back(); } } else { return redirect()->route("login")->with("result", "Email hoặc mật khẩu không đúng!"); } }
public function postLogin(LoginRequest $request) { if (\Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password')], $request->has('remember'))) { return redirect()->intended('home'); } else { return back()->withErrors(['WrongCreds' => 'Falsche Logindaten']); } }
public function auth(LoginRequest $request) { $username = $request->get('username'); $password = $request->get('password'); if ($this->auth->attempt(['username' => $username, 'password' => $password])) { return response()->json(['success' => true, 'msg' => 'Login Sukses!', 'user' => $this->auth->user()]); } return response()->json(['success' => false, 'msg' => 'Username atau Password Anda Salah!']); }
/** * Do Login * * @param LoginRequest $request * @return \Illuminate\Http\RedirectResponse */ public function postLogin(LoginRequest $request) { if (Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password')], $request->get('remember'))) { message()->success('Success!', 'You have logged in !'); return redirect()->intended('/todo'); } message()->error('Alert !', 'Wrong Username or password dude'); return redirect()->back()->withInput(); }
/** * 验证登录 * * @param LoginRequest $request * * @return $this|\Illuminate\Http\RedirectResponse */ public function postLogin(LoginRequest $request) { $user = $this->authRepository->attempt($request->get('username'), $request->get('password'), $request->has('remember')); if ($user) { event(new UserLogin(Auth::user())); // 触发登录事件 // intended 方法将会将用户重定向到登录之前用户想要访问的URL,在目标URL无效的情况下备用URI将会传递给该方法。 return redirect()->intended(route('dashboard.console')); } return back()->withInput()->withErrors(trans('auth.failed')); }
public function authenticate(\App\Http\Requests\LoginRequest $request) { // verify and login the user try { $this->authentication->authenticate($request->get('email'), $request->get('password')); // upon success, set some data into the session $request->session()->put('full_name', \Auth::User()->full_name); } catch (\L5Admin\Exceptions\ModelNotFoundException $error) { $request->session()->flash('error', 'User Not Found'); return back()->withInput(); } catch (\L5Admin\Exceptions\PasswordCheckException $error) { $request->session()->flash('error', 'Incorrect Password'); return back()->withInput(); } return redirect()->route('home'); }
/** * @param LoginRequest $request * @return \Illuminate\Http\RedirectResponse */ public function postLogin(LoginRequest $request) { $result = $this->auth->attempt($request->only(['email', 'password']), $request->get('remember', false)); if (!$result) { return redirect()->route('get.login')->with('message', 'ユーザー認証に失敗しました'); } return redirect()->route('admin.entry.index'); //return redirect()->route('auth.get.login'); }
/** * For login of Users * * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ public function login(LoginRequest $request) { /*if($request->has('remember') && $request->get('remember')=='on') { if(\Auth::attempt(['username'=>$request->get('username'),'password'=>$request->get('password')])) { User::where('id','=',\Auth::user()->id)->update(array('logged_in'=>'1'));//->update(array('logged_in'=>1)); \Flash::message('You are successfully login.'); return \Redirect::action('HomeController@dashboard');//,compact('users')); } }else {*/ if (\Auth::attempt(['username' => $request->get('username'), 'password' => $request->get('password')])) { User::where('id', '=', \Auth::user()->id)->update(array('logged_in' => '1')); //->update(array('logged_in'=>1)); \Flash::message('You are successfully login.'); return \Redirect::action('HomeController@dashboard'); //,compact('users')); } \Flash::error('Username and Password doesn\'t match'); return \Redirect::back(); //} }