コード例 #1
1
 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
0
 /**
  * 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']);
 }
コード例 #3
0
 /**
  * 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();
 }
コード例 #4
0
ファイル: AuthController.php プロジェクト: evolvaHQ/uwanja
 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');
 }
コード例 #5
0
 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');
             }
         }
     }
 }
コード例 #6
0
ファイル: AuthController.php プロジェクト: dmorgorg/photos
 /**
  * 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 : '/');
 }
コード例 #7
0
ファイル: AuthController.php プロジェクト: mauhftw/mizustats
 public function redirectPath()
 {
     if (\Auth::user()->isUser('user')) {
         return '/home';
     }
     return '/dashboard';
 }
コード例 #8
0
 /**
  * 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)]);
     }
 }
コード例 #9
0
ファイル: AuthController.php プロジェクト: Qeenslet/wireworks
 public function getRegister()
 {
     if (\Auth::user()) {
         return view('auth.register');
     } else {
         return redirect(url('/'));
     }
 }
コード例 #10
0
ファイル: AuthController.php プロジェクト: burflip/ddsi
 public function redirectPath()
 {
     // Logic that determines where to send the user
     if (\Auth::user()->type == 'admin') {
         return '/admin';
     }
     return '/dashboard';
 }
コード例 #11
0
 public function verify($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     if (Auth::once($credentials)) {
         return Auth::user()->id;
     }
     return false;
 }
コード例 #12
0
 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
0
 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);
 }
コード例 #14
0
ファイル: AuthController.php プロジェクト: TIunlam/proyek
 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());
 }
コード例 #15
0
 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("/");
     }
 }
コード例 #16
0
ファイル: AuthController.php プロジェクト: lyovkin/v2board
 /**
  * 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()]);
 }
コード例 #17
0
 /**
  * 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());
 }
コード例 #18
0
 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);
     }
 }
コード例 #19
0
 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';
     }
 }
コード例 #20
0
 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()]);
 }
コード例 #21
0
ファイル: AuthController.php プロジェクト: NikeshVilayil/Todo
 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');
     }
 }
コード例 #22
0
 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');
     }
 }
コード例 #23
0
ファイル: AuthController.php プロジェクト: prkeshri/getpanel
 /**
  * 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!');
     }
 }
コード例 #24
0
 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()]);
 }
コード例 #25
0
 /**
  * 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');
     }
 }
コード例 #26
0
 /**
  * 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()]);
 }
コード例 #27
0
ファイル: PasswordController.php プロジェクト: abada/webshop
 /**
  * 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'));
 }
コード例 #28
0
ファイル: UserController.php プロジェクト: tahirghori/dick
 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();
 }
コード例 #29
0
 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');
     }
 }
コード例 #30
0
 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' => 'Данные, введенные Вами не соответствуют нашим записям. Попробуйте еще раз?']);
 }