ahkeravi's avatar

laravel 419 proxy reauthentication required ?

i need solution for this error

0 likes
4 replies
bobbybouwmann's avatar

You get this error whenever your CSRF-token is incorrect or when your session has expired.

You need to provide more information about when this is happening and how, so we give you the correct solution for this.

ahkeravi's avatar

Thanks for reply @bobbybouwmann


    public function signin_doverify(Request $request) {

        $errors = new MessageBag();
        $validator = $this->validator($request->all());
        if ($validator->fails())
        {
          return redirect()
                ->back()
                ->withInput()
                ->withErrors($validator->errors());
        }

        $username_email = $_POST['username_email'];
        $password = $_POST['password'];


        $user_exists = $this->_signin->check_user_or_email_exists($username_email);
  
        if(count($user_exists) > 0) // if user name or email exists then check for pasword 
        {
            $check_password_match = $this->_signin->check_user_password_matches($user_exists[0]->id,$password);
            if(count($check_password_match) > 0) // if user id and password matches hen do login success
            {
                Session::put('loginemail', $user_exists[0]->email);
                Session::put('loginuserid', $user_exists[0]->id);
                Session::put('checkauthenticate',1); 
              
                if($user_exists[0]->role_id == 0) //superadmin
                {
                    Session::put('super_admin_info',$user_exists);
                    Session::put('login_type','super_admin');
                    return redirect('/dashboard');
                }
          else
        {
            $errors->add('username_email', 'Email doesn\'t exist.');
        }

        return redirect()
                ->back()
                ->withInput()
                ->withErrors($errors);

    }

this error comes in only some deskotop

bobbybouwmann's avatar
Level 88

This is probably an issue with the CSRF-token. Make sure you have this in your for

// Blade

<form action="/signin" method="POST">
	@csrf

	// Your form here
</form>

// Regular php

<form action="/signin" method="POST">
	<input type="hidden" name="_token" value="{{ csrf_token() }}">

	// Your form here
</form>

The session is normally set to 2 hours. If you're past this point, your CSRF-token is not valid anymore and you will get this 419 error.

Another issue here, don't use $_POST. This is unsafe since the input is not serialized. You can use the request object instead

$password = $request->input('password');

Please or to participate in this conversation.