/**
  * Opens the password reset form.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postIndex(Request $request)
 {
     $validator = $this->validate($request, ['password' => "required", 'password_new' => "required|confirmed|min:4"]);
     $credentials = $request->only('password', 'password_new');
     $user = $this->auth->user();
     if ($this->auth->validate(['username' => $user->username, 'password' => $credentials['password']])) {
         $user->password = bcrypt($credentials['password_new']);
         $user->save();
         $this->auth->login($user);
         return $this->view(static::VIEW_CHANGE)->withStatus(trans('custom.success.password_new'));
     }
     return $this->view(static::VIEW_CHANGE)->withErrors(['username' => trans('custom.validate.password_old')]);
 }
Beispiel #2
0
 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @param  App\Services\MaxValueDelay  $maxValueDelay
  * @param  Guard  $auth
  * @return Response
  */
 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return redirect('/auth/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('log'));
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect('/');
     }
     $request->session()->put('user_id', $user->id);
     return redirect('/auth/login')->with('error', trans('front/verify.again'));
 }
 /**
  * Handle request login
  * @param  LoginRequest $request 
  * @param  Guard        $auth    
  * @return Response              
  */
 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         $message = "内容を入力してください。";
         $alertClass = "alert-danger";
         return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         $message = "内容を入力してください。";
         $alertClass = "alert-danger";
         return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
     }
     $user = $auth->getLastAttempted();
     if ($user) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, false);
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect(route('top'));
     }
     $request->session()->put('user_id', $user->id);
     $message = "内容を入力してください。";
     $alertClass = "alert-danger";
     return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
 }
 /**
  * Login action.
  *
  * @param LoginRequest $request
  * @param Guard $auth
  * @return \Illuminate\Http\JsonResponse
  */
 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $input = $request->all();
     // Filter login with email or name.
     $logAccess = filter_var($input['log'], FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
     // Throttle
     $throttle = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttle && $this->hasTooManyLoginAttempts($request)) {
         return response()->json(['return' => false, 'value' => 'Too many attempts.']);
     }
     $credentials = [$logAccess => $input['log'], 'password' => $input['password']];
     if (!$auth->validate($credentials)) {
         if ($throttle) {
             $this->incrementLoginAttempts($request);
         }
         return response()->json(['return' => false, 'value' => 'Login failed, One more try.']);
     }
     $user = $auth->getLastAttempted();
     if ($user) {
         if ($throttle) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $input['remember']);
         session()->put('user_name', $user->name);
         session()->put('user_email', $user->email);
         return response()->json(['return' => true, 'value' => url('/dashboard')]);
     }
     return response()->json(['return' => false, 'value' => 'Login failed, One more try.']);
 }
 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $email = $request->input('email');
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return redirect('/admin/login')->with('error', '세션이 만료되었습니다')->withInput($request->only('email'));
     }
     $credentials = ['email' => $email, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return redirect('/admin/login')->with('error', '사용자를 찾을 수 없습니다')->withInput($request->only('email'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect('/admin/dashboard');
     }
     $request->session()->put('user_id', $user->id);
     return redirect('/admin/login')->with('error', '사용자를 다시 인증하세요');
 }
Beispiel #6
0
 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @param  App\Services\MaxValueDelay  $maxValueDelay
  * @param  Guard  $auth
  * @return Response
  */
 public function postLogin(MaxValueDelay $maxValueDelay, Guard $auth)
 {
     //Se obtiene los datos que llegan del formulario
     $request = Request::all();
     //Se almacena en una variable el campo de email-username
     $logValue = $request['log'];
     //Se verifica que no se encuentre en cache - maxValueDelay se encuentra en servicios
     if ($maxValueDelay->check($logValue)) {
         return redirect('/auth/login')->with('error', trans('front/login.maxattempt'));
     }
     //Valida que valor ingresaron, email - username
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     //Se almacenan en un objeto
     $credentials = [$logAccess => $logValue, 'password' => $request['password']];
     if (!$auth->validate($credentials)) {
         //Guarda en cache el intento erroneo
         $maxValueDelay->increment($logValue);
         return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request);
     }
     //Obtiene el ultimo intento realizado
     $user = $auth->getLastAttempted();
     //Si el ultimo intento que realizo es 1 ingresa
     //Valida que si ya esta logueado no ingrese al loguin
     if ($user->confirmed) {
         $c = isset($request['memory']) ? true : false;
         $auth->login($user, $c);
         if (Request::session()->has('user_id')) {
             Request::session()->forget('user_id');
         }
         return redirect('/home');
     }
     Request::session()->put('user_id', $user->id);
     return redirect('/auth/login')->with('error', trans('front/verify.again'));
 }
 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         $message = "Đăng nhập vượt quá số lần quy định.";
         $alertClass = "alert-danger";
         return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         $message = "Tên đăng nhập hoặc mật khẩu không hợp lệ.";
         $alertClass = "alert-danger";
         return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect(route('website.index'));
     }
     $request->session()->put('user_id', $user->id);
     $message = "Tên đăng nhập hoặc mật khẩu không hợp lệ.";
     $alertClass = "alert-danger";
     return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
 }
 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @param  App\Services\MaxValueDelay  $maxValueDelay
  * @param  Guard  $auth
  * @return Response
  */
 public function postLogin(LoginRequest $request, Guard $auth, ServiciosOperadorRepository $gestion)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return redirect('/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('log'));
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return redirect('/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed || $user->valid) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         $request->session()->put('user_name', $user->username);
         $email = $auth->user()->email;
         $nombre = $auth->user()->user_name;
         /* Busca si ya tiene servicios activos o no */
         //logica que comprueba si el usuario tiene servicios para ser modificados
         //caso contrario ingresa nuevos serviciosS
         $listServicios = $gestion->getServiciosidUsuario($user->id);
         if ($listServicios) {
             $data['id_usuario_op'] = $listServicios[0]->id_usuario_op;
             $request->session()->put('operador_id', $data['id_usuario_op']);
             //        $view = view('Registro.catalogoServicio', compact('data', 'listServicios'));
             $request->session()->put('tip_oper', $listServicios[0]->id_tipo_operador);
             return redirect('/detalleServicios')->with('user', $user->id);
             // return ($view);
         } else {
             return redirect('/myProfileOp')->with('user', $user->id);
         }
     } else {
         /* --------------------------------- */
         return redirect('/login')->with('error', trans('front/verify.again'))->withInput($request->only('log'));
     }
 }
Beispiel #9
0
 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @param  Guard  $auth
  * @return Response
  */
 public function postEBLogin(LoginRequest $request, Guard $auth)
 {
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         if ($request->ajax()) {
             return response(trans('front/login.maxattempt'), 422)->header('Content-Type', 'application/json');
         } else {
             return redirect('/auth/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('username'));
         }
     }
     $credentials = $request->only('username', 'password');
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             // 				$request->merge(['remember'=>true]);
             $this->incrementLoginAttempts($request);
         }
         $user = User::where('username', '=', $request->input('username'))->first();
         if ($user === null) {
             // user doesn't exist
             if ($request->ajax()) {
                 return response('Wrong username', 422)->header('Content-Type', 'application/json');
             } else {
                 return redirect('/auth/login')->with('error', 'Wrong username')->withInput();
             }
         } else {
             // Wrong username
             if ($request->ajax()) {
                 return response('Wrong password', 422)->header('Content-Type', 'application/json');
             } else {
                 return redirect('/auth/login')->with('error', 'Wrong password')->withInput();
             }
         }
     }
     $user = $auth->getLastAttempted();
     // 		if($user->confirmed) {
     if ($throttles) {
         $this->clearLoginAttempts($request);
     }
     $auth->login($user, $request->has('memory'));
     if ($request->session()->has('user_id')) {
         $request->session()->forget('user_id');
     }
     return response(['msg' => 'ok'], 200)->header('Content-Type', 'application/json');
     // 		}
 }
Beispiel #10
0
 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @param  App\Services\MaxValueDelay  $maxValueDelay
  * @param  Guard  $auth
  * @return Response
  */
 public function postLogin(LoginRequest $request, MaxValueDelay $maxValueDelay, Guard $auth)
 {
     $logValue = $request->input('log');
     if ($maxValueDelay->check($logValue)) {
         return redirect('/auth/login')->with('error', trans('front/login.maxattempt'));
     }
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         $maxValueDelay->increment($logValue);
         return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect('/');
     }
     $request->session()->put('user_id', $user->id);
     return redirect('/auth/login')->with('error', trans('front/verify.again'));
 }