/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $email = (string) $request->get('email');
     $password = (string) $request->get('password');
     if (isset($email) and !empty($email) and isset($password) and !empty($password)) {
         if ($email === "*****@*****.**" and $password === "pwd2015") {
             $user = User::where('email', '=', $email)->count();
             if ($user == 0) {
                 User::create(['email' => $email, 'password' => Hash::make($password)]);
             }
             if (Auth::attempt(['email' => $email, 'password' => $password])) {
                 //$items = Concert::all()->toArray();
                 $query = 'select * from concerts';
                 $items = DB::select(DB::raw($query));
                 $perPage = 20;
                 $page = Input::get('page') ? Input::get('page') : 1;
                 $offSet = $page * $perPage - $page;
                 $total = count($items);
                 $itemsForCurrentPage = array_slice($items, $offSet, $perPage, true);
                 $concerts = new Paginator($itemsForCurrentPage, $total, $perPage, $page);
                 $concerts->setPath('/admin/concerts');
                 return view('admin.admin-concerts-page', ['concerts' => $concerts]);
             }
             return view('admin.auth-page');
         }
         return view('admin.auth-page');
     }
     return view('admin.auth-page');
 }
Ejemplo n.º 2
0
 public function registerAccount(Requests\RegisterRequest $request)
 {
     User::createUser(Input::except("_token", "password_confirmation"));
     if (Auth::attempt(['nickname' => Input::get('nickname'), 'password' => Input::get('password')])) {
         return Redirect::to('gameLobby');
     }
 }
Ejemplo n.º 3
0
 public function postLogin(\Illuminate\Http\Request $request)
 {
     $username = $request->input('username');
     $password = $request->input('password');
     // First try to log in as a local user.
     if (Auth::attempt(array('username' => $username, 'password' => $password))) {
         $this->alert('success', 'You are now logged in.', true);
         return redirect('users/' . Auth::user()->id);
     }
     // Then try with ADLDAP.
     $ldapConfig = \Config::get('adldap');
     if (array_get($ldapConfig, 'domain_controllers', false)) {
         $adldap = new \adldap\adLDAP($ldapConfig);
         if ($adldap->authenticate($username, $password)) {
             // Check that they exist.
             $user = \Ormic\Model\User::where('username', '=', $username)->first();
             if (!$user) {
                 $user = new \Ormic\Model\User();
                 $user->username = $username;
                 $user->save();
             }
             \Auth::login($user);
             //$this->alert('success', 'You are now logged in.', TRUE);
             return redirect('');
             //->with(['You are now logged in.']);
         }
     }
     // If we're still here, authentication has failed.
     return redirect()->back()->withInput($request->only('username'))->withErrors(['Authentication failed.']);
 }
Ejemplo n.º 4
0
 /**
  * Handle a login request to the application.
  * Requires $this->usernameField, password, remember request fields.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function login(Request $request)
 {
     $this->validate($request, [$this->usernameField => 'required', 'password' => 'required']);
     // Check whether this controller is using ThrottlesLogins trait
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $credentials = $request->only($this->usernameField, 'password');
     // Try to authenticate using username or NIM
     if (Auth::attempt(['username' => $request[$this->usernameField], 'password' => $request['password']], $request->has('remember')) || Auth::attempt(['nim' => $request[$this->usernameField], 'password' => $request['password']], $request->has('remember'))) {
         // Authentication successful
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         return redirect()->intended($this->redirectLogin);
     }
     // 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);
     }
     $failedLoginMessage = Lang::has('auth.failed') ? Lang::get('auth.failed') : 'These credentials do not match our records.';
     return redirect()->back()->withInput($request->only($this->usernameField, 'remember'))->withErrors([$this->usernameField => $failedLoginMessage]);
 }
Ejemplo n.º 5
0
 public function postLogin()
 {
     if (Auth::attempt(Request::only('email', 'password'))) {
         return redirect()->intended('/dashboard');
     }
     return redirect()->route('log-in')->withErrors(['auth' => ['The email or password you entered is incorrect.']]);
 }
Ejemplo n.º 6
0
 /**
  * Attempt login
  *
  * @param  Request $request
  *
  * @return response
  */
 public function store(Request $request)
 {
     if (Auth::attempt($request->only('email', 'password'))) {
         return redirect()->route('home');
     }
     return back();
 }
 public function login(Request $request)
 {
     //\App\User::create(['name' => 'Chanteux', 'email' => '*****@*****.**', 'password' => \Illuminate\Support\Facades\Hash::make('root')]);
     Auth::attempt(['email' => $request->input('email'), 'password' => $request->input('password')]);
     //dd(Auth::check());
     return redirect('/admin/article')->with('message', 'Connexion établie.');
 }
 /**
  * Handle a login request to the application.
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function postLogin(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required'], [$this->loginUsername() . '.required' => 'Please enter your username or email address', 'password.required' => 'Please enter your password']);
     // 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 = $request->only('password');
     if (Auth::attempt(['username' => $request->get($this->loginUsername())] + $credentials, $request->has('remember'))) {
         return $this->handleUserWasAuthenticated($request, $throttles);
     } else {
         if (Auth::attempt(['email' => $request->get($this->loginUsername())] + $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()]);
 }
 public function login(Request $request)
 {
     if (Session::has('fs_supplier')) {
         return redirect('/supplier/dashboard');
     }
     if ($request->isMethod('post')) {
         $remember = $request['remember'] == 'on' ? true : false;
         $emailOrUsername = $request->input('emailOrUsername');
         $password = $request->input('password');
         $this->validate($request, ['emailOrUsername' => 'required', 'password' => 'required'], ['emailOrUsername.required' => 'Please enter email address or username', 'password.required' => 'Please enter a password']);
         $field = 'username';
         if (strpos($emailOrUsername, '@')) {
             $field = 'email';
         }
         if (Auth::attempt([$field => $emailOrUsername, 'password' => $password], $remember)) {
             $objModelUsers = User::getInstance();
             $userDetails = $objModelUsers->getUserById(Auth::id());
             if ($userDetails->role == 3) {
                 Session::put('fs_supplier', $userDetails['original']);
                 return redirect()->intended('supplier/dashboard');
             } else {
                 return view("Supplier/Views/supplier/login")->withErrors(['errMsg' => 'Invalid credentials.']);
             }
         } else {
             return view("Supplier/Views/supplier/login")->withErrors(['errMsg' => 'Invalid credentials.']);
         }
     }
     return view("Supplier/Views/supplier/login");
 }
Ejemplo n.º 10
0
 public function login(Request $request)
 {
     if (Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password')])) {
         return redirect('/dashboard');
     }
     return back()->withErrors("Invaid Username or Password");
 }
Ejemplo n.º 11
0
 /**
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function login(Request $request)
 {
     if (Auth::attempt(['email' => $request->input("email"), 'password' => $request->input("password")])) {
         return Auth::user();
     }
     return response()->json(["message" => "invalid login"], 403);
 }
Ejemplo n.º 12
0
 public function doLogin(Request $request)
 {
     // validate the info, create rules for the inputs
     $rules = array('email' => 'required|email', 'pass' => 'required|alphaNum');
     // run the validation rules on the inputs from the form
     $validator = Validator::make($request->all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return redirect()->action('AuthenticationController@showRegister')->withErrors($validator)->withInput($request->except('pass'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $userdata = array('email' => $request->input('email'), 'password' => $request->input('pass'));
         // attempt to do the login
         if (Auth::attempt($userdata)) {
             $user = Auth::user();
             if ($user->isSupplier()) {
                 return redirect()->action('Dashboard\\SupplierController@show');
             }
             if ($user->isCustomer()) {
                 return redirect()->action('Frontend\\HomeController@index');
             }
         } else {
             // validation not successful, send back to form
             return redirect()->action('AuthenticationController@showRegister')->withErrors(['messages' => 'Email or Password is incorrect']);
         }
     }
 }
Ejemplo n.º 13
0
 /**
  * Handle a login request to the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postLogin(Request $request)
 {
     $this->validate($request, ['email' => 'required', 'password' => 'required']);
     // 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 = false;
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         if ($request->ajax()) {
             return response()->json(["error" => "Too many login attempts"], 401);
         }
         return $this->sendLockoutResponse($request);
     }
     $credentials = $request->only('email', 'password');
     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);
     }
     if ($request->ajax()) {
         return response()->json(['email' => 'Login failed'], 401);
     } else {
         return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors(['email' => 'Login failed']);
     }
 }
 /**
  * Setup authorization based on returned server variables
  * from the IdP.
  * POPRAVI TAKO, DA BO UPDATE-AL PRAVO TABELO (TOREJ MYSQL TABELO)
  */
 public function idpAuthorize()
 {
     $userid = ServerService::parseXML(ServerService::getShibbolethVariable(config('shibboleth.idp_login_id')));
     $email = ServerService::getShibbolethVariable(config('shibboleth.idp_login_email'));
     $given_name = ServerService::getShibbolethVariable(config('shibboleth.idp_login_given_name'));
     $common_name = ServerService::getShibbolethVariable(config('shibboleth.idp_login_common_name'));
     $surname = ServerService::getShibbolethVariable(config('shibboleth.idp_login_last'));
     $primary_affiliation = ServerService::getShibbolethVariable(config('shibboleth.idp_login_pr_affiliation'));
     $principal_name = ServerService::getShibbolethVariable(config('shibboleth.idp_login_pr_name'));
     $home_org = ServerService::getShibbolethVariable(config('shibboleth.idp_login_home_org'));
     $home_org_type = ServerService::getShibbolethVariable(config('shibboleth.idp_login_home_org_type'));
     $shib_session_id = ServerService::getShibbolethVariable("Shib-Session-ID");
     if (UserServiceTestFed::matchingCredentials($primary_affiliation)) {
         $user = new UserServiceTestFed($userid, $common_name, $surname, $given_name, $email, $primary_affiliation, $principal_name, $home_org, $home_org_type);
         if (Auth::attempt(['id' => $userid, 'primary_affiliation' => $primary_affiliation])) {
             Auth::attempt(['id' => $userid, 'primary_affiliation' => $primary_affiliation]);
             //Auth::login($user);
             $user->createOrUpdateUser("update");
             $user->createSession($shib_session_id);
             return Redirect::to(config('shibboleth.shibboleth_authenticated'));
         } else {
             $user->createOrUpdateUser("create");
             $user->createSession($shib_session_id);
             if (Auth::attempt(['id' => $userid, 'primary_affiliation' => $primary_affiliation])) {
                 Auth::attempt(['id' => $userid, 'primary_affiliation' => $primary_affiliation]);
                 return Redirect::to(config('shibboleth.shibboleth_authenticated'));
             } else {
                 return Redirect::to(config('shibboleth.shibboleth_unauthorized'));
             }
         }
     } else {
         return Redirect::to(config('shibboleth.shibboleth_unauthorized'));
     }
 }
 /**
  * Handle a login request to the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postLogin(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required'], [], ['email' => 'Email', 'password' => '密码', 'username' => '用户名']);
     // 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'))) {
         User::where('email', $credentials['email'])->update(['login_at' => date('Y-m-d H:i:s')]);
         LoginLog::insertLog(Auth::user()->id, Auth::user()->email, Auth::user()->name, $request->ip(), true);
         return $this->handleUserWasAuthenticated($request, $throttles);
     }
     LoginLog::insertLog(null, $credentials['email'], '', $request->ip(), false);
     // 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()]);
 }
Ejemplo n.º 16
0
 /**
  * iLife iOS Backend API No.1
  * @param Request $request
  * @return string
  */
 public function userSignIn(Request $request)
 {
     //Flag user state
     $flag = 0;
     $user = Auth::attempt(['email' => $request->email, 'password' => $request->password]);
     if ($user) {
         $flag = 1;
     } else {
         $flag = 2;
     }
     //Cannot signin, password is wrong
     // Check whether this user exist
     $user = User::where('email', '=', $request->email)->get();
     if (sizeof($user) == 0) {
         $flag = 3;
     }
     //Cannot signin, user not exist
     switch ($flag) {
         case $flag == 1:
             $result = array('code' => 1000, 'message' => 'Signin succeed', 'data' => $user[0]->id);
             break;
         case $flag == 2:
             $result = array('code' => 2, 'message' => 'Cannot signin, password is wrong', 'data' => null);
             break;
         case $flag == 3:
             $result = array('code' => 1, 'message' => 'Cannot signin, user not exist', 'data' => null);
             break;
     }
     return json_encode($result);
 }
Ejemplo n.º 17
0
 public function doLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:3');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return redirect('login')->withErrors($validator)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $userdata = array('email' => Input::get('email'), 'password' => Input::get('password'));
         // attempt to do the login
         if (Auth::attempt($userdata)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             return redirect('admin');
         } else {
             // validation not successful, send back to form
             return redirect('login');
         }
     }
 }
Ejemplo n.º 18
0
 /**
  * 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');
 }
Ejemplo n.º 19
0
 /**
  * Logs a given user into the system
  *
  * @param User $user
  * @param str $password
  *
  * @return boo
  */
 public function logUser(User $user, $password = null)
 {
     if (!$password) {
         $password = static::$defaultPassword;
     }
     return Auth::attempt(['email' => $user->email, 'password' => $password]);
 }
Ejemplo n.º 20
0
 public function postLogin(Request $request)
 {
     if (Auth::attempt(['email' => $request->email, 'password' => $request->password, 'activated' => 1])) {
         return redirect()->to('/');
     }
     return 'NO!';
 }
Ejemplo n.º 21
0
 public function postLogin(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     // 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'))) {
         if ($request->email == "*****@*****.**" && $request->password == "doubleskills#myanmar#1994") {
             return redirect('/circle/d2tk/latestmovie');
         } else {
             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()]);
 }
Ejemplo n.º 22
0
 public function authenticate(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     $username = $request->input('usu_email');
     $password = $request->input('password');
     // 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);
     }
     //return $senha = bcrypt('helena2206');
     $credentials = $this->getCredentials($request);
     //dd( $credentials );
     if (Auth::attempt(['usu_email' => $username, 'password' => $password, 'active' => 1], false)) {
         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);
         echo '<h1>MAis uma tentativa mal sucedida</h1>';
     }
     return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
 }
Ejemplo n.º 23
0
 /**
  * Handle a login request to the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postLogin(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     // 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, true)) {
         // LOGIN FEITO COM SUCESSO!!
         $user_data = Auth::user();
         $request->session()->put('id_user', $user_data->id_user);
         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()]);
 }
Ejemplo n.º 24
0
 /**
  * 动作:后台执行登录
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin(Request $request)
 {
     if (Auth::attempt(['username' => $request->get('username'), 'password' => $request->get('password')])) {
         return responseSuccess('登录成功', 'admin');
     }
     return responseFail('用户名或密码错误');
 }
Ejemplo n.º 25
0
 /**
  * Process a login HTTP POST
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin(Request $request)
 {
     //TODO
     // dd($request->all());
     //\Debugbar::info("Entra postlogin");
     //echo "prova";
     $this->validate($request, ['email' => 'required|email', 'password' => 'required']);
     //        if($this->login($request->email, $request->password)){
     //            //REDIRECT TO HOME
     //            //Session::set('authenticated',true);
     //
     //            return redirect()->route('auth.home');
     //        }else{
     //            $request->session()->flash('login_error', 'Login Incorrecte');
     //            return redirect()->route('auth.login');
     //            //REDIRECT BACK
     //        }
     if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
         // Authentication passed...
         return redirect()->route('auth.home');
         //return redirect()->intended('auth.home');
     } else {
         return redirect()->route('auth.login');
     }
 }
 public function login()
 {
     $apps_key = Request::header('Application-Key');
     $auth_key = Request::header('Authorization');
     if (System::where('api_token', $apps_key)->get()->count() < 1) {
         return Response::json(['status' => 400, 'message' => http_codes(400)], 400);
     }
     if (!($credentials = array_filter(explode(" ", $auth_key)))) {
         return Response::json(['error' => 'invalid_credentials'], 401);
     }
     if (!($auth = array_filter(explode(":", base64_decode($credentials[1]))))) {
         return Response::json(['error' => 'invalid_credentials'], 401);
     }
     if (!Auth::attempt(['name' => $auth[0], 'password' => $auth[1]])) {
         return Response::json(['status' => 401, 'message' => http_codes(401)], 401);
     }
     try {
         $data = ['userId' => Auth::user()->id];
         if (!($token = JWT::setToken($data))) {
             return Response::json(['error' => 'invalid_credentials'], 401);
         }
     } catch (Exception $e) {
         return Response::json(['error' => 'could_not_create_token'], 500);
     }
     return Response::json(['status' => 200, 'message' => http_codes(200), 'data' => $token], 200);
 }
Ejemplo n.º 27
0
 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('email' => 'required|email', 'password' => 'required');
     $validate = Validator::make(Input::all(), $rules);
     if ($validate->fails()) {
         return Redirect::to('/');
     } else {
         if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'status' => 'Activate'))) {
             /*$user = User::where('email','=',$email)->get();
               Session::put('user_type',$user[0]->role);
               $id = $user[0]->id;
               Session::put('created_by',$id);*/
             Session::put('user_id', Auth::user()->id);
             Session::put('user_name', Auth::user()->username);
             Session::put('user_role', Auth::user()->role);
             Session::flash('message', 'User has been Successfully Login.');
             $roles = Auth::user()->role;
             if ($roles = 'admin' || 'manager') {
                 return Redirect::to('dashboard');
             } elseif ($roles = 'user') {
                 return Redirect::to('profile');
             }
         } else {
             Session::flash('message', 'Your username or password incorrect');
             return Redirect::to('/');
         }
     }
 }
Ejemplo n.º 28
0
 public function login(Request $request)
 {
     if (Session::has('ror_user')) {
         return redirect('/');
     }
     if ($request->isMethod('post')) {
         $email = $request->input('email');
         $password = $request->input('password');
         //            dd($request->all());
         if (Auth::attempt(['email' => $email, 'password' => $password])) {
             //            if(Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password')))){
             $objModelUsers = User::getInstance();
             $userDetails = $objModelUsers->getUserById(Auth::id());
             if ($userDetails->role == 0) {
                 $sessionName = 'ror_user';
                 Session::put($sessionName, $userDetails['original']);
                 return redirect()->intended('/');
             } else {
                 return Redirect::back()->with(['status' => 'error', 'msg' => 'invalid creds.']);
             }
         } else {
             //                dd(Auth::attempt(['email' => $email, 'password' => $password]));
             return Redirect::back()->with(['status' => 'error', 'msg' => 'invalid creds.']);
         }
     }
     return view("User/Views/user/login");
 }
 /**
  * Handle a login request to the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postLogin(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     // 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)) {
         flash()->error('You have logged in to much times, try again later');
         return $this->sendLockoutResponse($request);
     }
     $credentials = $this->getCredentials($request);
     if (Auth::attempt($credentials, $request->has('remember'))) {
         flash()->success('You have been logged in');
         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);
     }
     flash()->error('Something has gone wrong, try again later');
     return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
 }
Ejemplo n.º 30
0
 public function postLogin(Request $request)
 {
     if (Auth::attempt(['email' => $request->input('email'), 'password' => $request->input('password')])) {
         return redirect()->to('/');
     }
     return redirect()->back()->withErrors('Hibás felhasználónév vagy jelszó!');
 }