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); } }
/** * Create a new authentication controller instance. * * @return void */ public function __construct() { if (\Auth::check()) { $this->redirectTo = url(\Auth::user()->slug); } $this->middleware('guest', ['except' => 'logout']); }
/** * Log the user out of the application. * * @return \Illuminate\Http\Response */ public function getLogout() { $user = Auth::user(); $user->status = 'unavailable'; $user->save(); return $this->logout(); }
public function facebookRedirect() { // Automatically log in existing users // or create a new user if necessary. SocialAuth::login('facebook', function ($user, $details) { $existing_user = User::where('email', $details->email)->first(); if ($existing_user !== NULL) { $existing_user->avatar = $details->avatar; $existing_user->save(); return $existing_user; // Tell the package to use this user instead of creating a new one. } $user->name = $details->full_name; $user->avatar = $details->avatar; $user->email = $details->email; $user->save(); $roles_allowed = [2]; $user->syncRoles($roles_allowed); }); // Current user is now available via Auth facade $user = Auth::user(); if ($user->wasRecentlyCreated == TRUE) { return redirect('payment')->with('message', 'Update Payment details!'); } return redirect()->intended('/backend/home'); }
public function postRegister(Request $request) { $validator = $this->registrar->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } $this->auth->login($this->registrar->create($request->all())); $id = DB::getPdo()->lastInsertId(); $user = \Auth::user(); if (Input::get('state') === 'company') { $user->isCompany = 1; $user->save(); return Redirect('company/project'); } else { if (Input::get('state') === 'student') { $user->isStudent = True; $user->save(); return Redirect('profile'); } else { if (Input::get('state') === 'expertise') { $user->isExpertise = True; $user->save(); return Redirect('profile'); } } } }
/** * Log the user out of the application. * * @return \Illuminate\Http\Response */ public function getLogout() { $user = \Auth::user()->name; \Auth::logout(); \Session::flash('flash_message', $user . ': You have been logged out.'); return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/'); }
public function redirectPath() { if (\Auth::user()->isUser('user')) { return '/home'; } return '/dashboard'; }
/** * Reset the given user's password. * * @param Request $request * @return Response */ public function postReset(Request $request) { $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed']); $credentials = $request->only('email', 'password', 'password_confirmation', 'token'); // print_r($credentials); // die; $response = $this->passwords->reset($credentials, function ($user, $password) { echo "reset password"; die; $user->password = bcrypt($password); $user->save(); $this->auth->login($user); }); switch ($response) { case PasswordBroker::PASSWORD_RESET: $user = \Auth::user(); if ($user->email_activated != '1') { $user->email_activated = '1'; $user->email_activated_at = new \DateTime(); $user->save(); } return redirect($this->redirectPath()); default: return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]); } }
public function getRegister() { if (\Auth::user()) { return view('auth.register'); } else { return redirect(url('/')); } }
public function redirectPath() { // Logic that determines where to send the user if (\Auth::user()->type == 'admin') { return '/admin'; } return '/dashboard'; }
public function verify($username, $password) { $credentials = ['email' => $username, 'password' => $password]; if (Auth::once($credentials)) { return Auth::user()->id; } return false; }
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!'); }
public function getUser() { $responseData = \Auth::user()->toArray(); $responseData['pingBaseUrl'] = \App\Ping::baseUrl(); $responseData['avatar'] = \Gravatar::get($responseData['email']); unset($responseData['id']); unset($responseData['updated_at']); return response($responseData, 200); }
protected function handleUserWasAuthenticated(Request $request, $throttles) { if ($throttles) { $this->clearLoginAttempts($request); } if (method_exists($this, 'authenticated')) { return $this->authenticated($request, Auth::user()); } return redirect()->intended($this->redirectPath()); }
public function postLogin(Request $request) { $auth = \Auth::attempt(['email' => $request->input('email'), 'password' => $request->input('password')]); if ($auth) { \Session::set('user', \Auth::user()); return redirect("/home"); } else { return redirect("/"); } }
/** * Handle a login request to the application. * * @param Request $request * @return \Illuminate\Http\Response */ public function postLogin(Request $request) { $this->validate($request, ['email' => 'required|email', 'password' => 'required']); $credentials = $request->only('email', 'password'); if ($this->auth->attempt($credentials, $request->has('remember'))) { if (\Auth::user()->last_login < date('Y-m-d')) { DB::table('users')->where('id', '=', \Auth::user()->id)->update(array('ads_rise' => 5, 'last_login' => new Carbon())); } return redirect()->intended($this->redirectPath()); } return redirect($this->loginPath())->withInput($request->only('email', 'remember'))->withErrors(['email' => $this->getFailedLoginMessage()]); }
/** * Send the response after the user was authenticated. * * @param \Illuminate\Http\Request $request * @param bool $throttles * @return \Illuminate\Http\Response */ protected function handleUserWasAuthenticated(Request $request, $throttles) { //Set avatar in the session. \Session::put('auth_photo', \Auth::user()->avatar); if ($throttles) { $this->clearLoginAttempts($request); } if (method_exists($this, 'authenticated')) { return $this->authenticated($request, \Auth::user()); } return redirect()->intended($this->redirectPath()); }
public function resendEmail() { $user = \Auth::user(); if ($user->resent >= 3) { return view('auth.tooManyEmails')->with('email', $user->email); } else { $user->resent = $user->resent + 1; $user->save(); $this->sendEmail($user); return view('auth.activateAccount')->with('email', $user->email); } }
public function redirectPath() { //add further kinds of logic, i.e. the way in which redirect to lecturer, admin and phd student panels if (\Auth::user()->role == 'Administrator') { return '/Admin-Dashboard'; } if (\Auth::user()->role == 'Lecturer') { return '/Lecturer-Dashboard'; } if (\Auth::user()->role == 'PHD Student') { return '/PHDStudent-Dashboard'; } }
public function postLogin(Request $request) { $this->validate($request, ['email' => 'required|email', 'password' => 'required']); $credentials = $request->only('email', 'password'); if ($this->auth->attempt($credentials, $request->has('remember'))) { if (\Auth::user()->role == 1) { return redirect()->intended($this->redirectPath()); } else { return redirect('/'); } } return redirect($this->loginPath())->withInput($request->only('email', 'remember'))->withErrors(['email' => $this->getFailedLoginMessage()]); }
public function logincheck() { $email = \Input::get('username'); $password = \Input::get('password'); if (\Auth::attempt(['email' => $email, 'password' => $password, 'status' => 'active'])) { if (\Auth::user()->roll_id == 1) { return \View::make('adminhome'); } else { return \View::make('userhome'); } } else { return \View::make('index'); } }
protected function handleUserWasAuthenticated(Request $request, $throttles) { if ($throttles) { $this->clearLoginAttempts($request); } if (method_exists($this, 'authenticated')) { return $this->authenticated($request, Auth::user()); } if (Entrust::hasRole('admin')) { return redirect()->intended('admin/utama'); } else { return redirect()->intended('home'); } }
/** * Handle a registration request for the application. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function register(Request $request) { $validator = $this->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } $this->create($request->all()); if (!\Auth::user()) { \Auth::guard($this->getGuard())->login($this->create($request->all())); return redirect($this->redirectPath()); } else { return redirect()->action('Auth\\UserController@getIndex')->with('message_type', 'success')->with('message', 'Successfully created! Edit them to add to groups!'); } }
public function postLogin(Request $request) { $this->validate($request, ['email' => 'required|email', 'password' => 'required']); $credentials = $request->only('email', 'password'); if ($this->auth->attempt($credentials, $request->has('remember'))) { $user = \Auth::user(); if ($user->accessible == 0) { \Auth::logout(); return redirect()->back()->withErrors(['Your Account has been blocked']); } else { return redirect()->intended($this->redirectPath()); } } return redirect($this->loginPath())->withInput($request->only('email', 'remember'))->withErrors(['email' => $this->getFailedLoginMessage()]); }
/** * Handle an authentication attempt. * * @return Response */ public function authenticate() { $username = \Request::input('username'); $password = \Request::input('password'); if (\Auth::attempt(['username' => $username, 'password' => $password])) { // Authentication passed... if (\Auth::user()->user_type == 1) { return redirect()->intended('admin/dashboard'); } else { return redirect()->intended('users/dashboard'); } } else { return redirect()->intended('auth/login')->withInput()->with('error', 'Error: Invalid login. Please try again'); } }
/** * Override the default postLogin method * to add JWT support. * * @param Request $request * @return $this */ public function postLogin(Request $request) { $this->validate($request, ['email' => 'required|email', 'password' => 'required']); $credentials = $request->only('email', 'password'); if (\Auth::attempt($credentials, $request->has('remember'))) { if (\Auth::user()->roles() == null || !in_array('web', \Auth::user()->roles()->lists('name', 'id')->toArray())) { \Auth::logout(); return redirect($this->loginPath())->withErrors(['error' => 'Δεν έχετε πρόσβαση στη σελίδα']); } //if the login is successful, save the jwt at a cookie $jwt = JWTService::setCookie(); return redirect()->to($this->redirectPath())->withCookie(cookie()->forever('jwtToken', $jwt)); } return redirect($this->loginPath())->withInput($request->only('email', 'remember'))->withErrors(['email' => $this->getFailedLoginMessage()]); }
/** * Reset the given user's password. * * @param Request $request * @return Response */ public function postDefine(Request $request) { $v = \Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required|different:old_password|min:6', 'old_password' => 'required'], ['password.different' => 'Le champ nouveau mot de passe doit être différent du mot de passe actuel']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); } $email = $request->input('email'); $password = $request->input('password'); $old_password = $request->input('old_password'); if (\Auth::attempt(['email' => $email, 'password' => $old_password])) { $user = \Auth::user(); $user->password = bcrypt($password); $user->save(); \Auth::login($user); return redirect('user')->with(['status' => 'success', 'message' => 'Votre mot de passe a bien été changé']); } return redirect()->back()->with(['status' => 'danger', 'message' => 'Les identifiants email / mot de passe ne correspondent pas'])->withInput($request->only('email')); }
public function postAccountInfo(Request $request) { // validate the name $validation_rules["name"] = "required|min:5"; // if the email has changed, validate that too if (\Auth::user()->email != $request->input('email')) { $validation_rules["email"] = "required|email|min:5|unique:users"; } $validator = \Validator::make($request->all(), $validation_rules); if ($validator->fails()) { // The given data did not pass validation return redirect()->back()->withInput()->withErrors($validator->errors()); } // update the info $user = User::findOrFail(\Auth::user()->id); $user->name = $request->input('name'); $user->email = $request->input('email'); $user->save(); // set a success/error message \Alert::success(trans('auth.information_updated'))->flash(); // redirect to the edit personal info page return redirect()->back(); }
protected function handleUserWasAuthenticated(Request $request, $throttles) { if ($throttles) { $this->clearLoginAttempts($request); } if (method_exists($this, 'authenticated')) { return $this->authenticated($request, Auth::user()); } if (Entrust::hasRole('admin')) { return redirect()->intended('admin'); } elseif (Entrust::hasRole('akademik')) { return redirect()->intended('akademik/home'); } elseif (Entrust::hasRole('kemahasiswaan')) { return redirect()->intended('kemahasiswaan/home'); } elseif (Entrust::hasRole('rektor')) { return redirect()->intended('rektor/home'); } elseif (Entrust::hasRole('dekan')) { return redirect()->intended('dekan/home'); } elseif (Entrust::hasRole('prodi')) { return redirect()->intended('prodi/home'); } else { return redirect()->intended('home'); } }
public function postLogin(Request $request) { if ($this->auth->attempt($request->only('name', 'password'))) { /* | | Putting activity into log | */ $activityToLog = new ActivityLog(); $activityToLog->activity = "User logged in! Login: "******"User not logged in! Login: " . implode(Input::only('name')); $activityToLogFail->save(); return redirect('auth/login')->withErrors(['name' => 'Данные, введенные Вами не соответствуют нашим записям. Попробуйте еще раз?']); }