greenlight icon indicating copy to clipboard operation
greenlight copied to clipboard

[BUG] After successfull signin when we navigate back using browser back button to signin page causes unexpected behaviour

Open rautniraj opened this issue 8 months ago • 2 comments

The issue is after we signup and navigate back using browser back button to signin page again and when we again try to signin we get Unauthorized request and user fails to signin.

Issue facing with version - 3.5.2 (issue is also there with previous 4 to 5 versions)

Steps to recreate the issue -

  1. Signin with your credential
  2. You will directed to rooms page
  3. Navigate to previous page using browser back button on top left
  4. You will land on signin page but the top navbar still remains the same as if user is logged in.
  5. Try to login gain by trying to enter your credential (I have tried both - using same credential or different valid credential)
  6. You will see error toast in bottom right corner
  7. Again clicking browser refresh button we see that we again get navigated successfully to room page.

You can find the same in video (I have kept open the developers tab to show you network log)

https://drive.google.com/file/d/18BhfjCxX7C2WfE6LKFFLVi3j2V9graF2/view?usp=sharing

This is the server log that i got -

Started POST "/gl/api/v1/sessions.json" for 192.168.172.183 at 2025-04-21 17:23:56 +0530 Cannot render console from 192.168.172.183! Allowed networks: 127.0.0.0/127.255.255.255, ::1 Processing by Api::V1::SessionsController#create as JSON Parameters: {"session"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "extend_session"=>false}, "token"=>"[FILTERED]"} User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."session_token" = $1 LIMIT $2 [["session_token", "[FILTERED]"], ["LIMIT", 1]] ↳ app/controllers/application_controller.rb:29:in current_user' Role Load (0.4ms) SELECT "roles".* FROM "roles" WHERE "roles"."id" = $1 LIMIT $2 [["id", "60c1465f-7a1b-42e4-a825-0b3a5651bddb"], ["LIMIT", 1]] ↳ app/models/user.rb:210:in super_admin?' [active_model_serializers] Rendered ActiveModel::Serializer::Null with Hash (0.07ms) Filter chain halted as :ensure_unauthenticated rendered or redirected Completed 401 Unauthorized in 8ms (Views: 0.6ms | ActiveRecord: 0.9ms (2 queries, 0 cached) | GC: 0.0ms)

rautniraj avatar Apr 21 '25 12:04 rautniraj

How i fixed this -

Not allowing to navigate to signin page again by checking user session on signin page and redirecting them back to rooms page.

I dont feel this is a good solution. Hope for better idea.

rautniraj avatar Apr 22 '25 05:04 rautniraj

@farhatahmad please review if time permits :)

rautniraj avatar May 13 '25 18:05 rautniraj