-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
seeing other users data after login/out with different users on ionic #375
Comments
I see now that even before the sign in a request is being made by the client to validate the token from what I assume is the previous session:
So my guess is that the source of this token is not properly updated on cordova/ionic after a sign_in. I'll try to trace it tomorrow. |
@abhayastudios I'm having the exact same issue! After a previously logged in User1 logged out, User2 will get authenticated back in with User1's session!! Except I'm using a React.js frontend with j-toker. This is a really serious issue, I'm also searching for ways to solve it... |
@ianchen06 does it happen to you also in a cordova/ionic project only? are you testing on android/iphone? |
@abhayastudios I have not tested it on mobile yet, but it seems to be related to this pull request? @lynndylanhurley Have you seen others reporting this issue? Thanks |
When I run 'clear data' on android for the ionic application then the next login will work ok until I login with another user, so it is definitely something with the localStorage. @ianchen06 what storage are you using? cookies (default) or localStorage? |
I'm using cookies and have also this issue (2nd user get previous user data).
|
I have same issue in my angular web app. I just don't know what to do for my users. Some of my users access the same computer and things have become a real big mess. Manually deleting the |
I've currently reverted to version |
I also had the same problem with logging user using email and oauth on the same device. In my rails console, I got this warning message, "Can't verify CSRF token authenticity", when trying to sign user out. Started DELETE "/api/v1/auth/sign_out" for xxx.xxx.x.xxx at 2015-10-02 00:24:42 +0700 To solve my problem, I added :destroy in the exception in my session controller. #################### def create def resource_params end And from client side I need to invalidate tokens after successfully sign out. #################### After that, everything is fine. |
+1 to @stephenbaidu. I was experiencing this problem on a mobile project and reverting back 0.1.31 fixed it. |
@mikeorr85 I also had to peg devise itself at |
Had the same problem. Turns out Rails CSRF protection prevented devise token auth from destroying the session: Processing by Users::SessionsController#destroy as JSON solved by: STEP 2: Calling $auth.invalidateTokens() after $auth.signOut() as per @makarakao |
Glad I took a second look at this. I was able to get passed my trouble while upgrading back to the latest version (0.1.36) simply by overriding the sessions controller as @makarakao originally posted. routes.rb
controllers/devise_token_auth_overrides/sessions_controller.rb
|
Can you guys please try out version |
|
That's great! Thx @mikeorr85!! |
Absolutely. Thank you for maintaining the gem! |
I can confirm that with 0.1.37.beta2 the issue is resolved!! WOOHOO :) Thanks a lot! |
😃 |
Fast-forward to 2018 and I had the same issue with version 0.1.42 in an Angular app (no Ionic involved though) - thanks to @makarakao and @ryankc33 I noticed that I was also getting the "Can't verify CSRF token authenticity" warning message. Adding the Note that you need to include In my case I didn't have to call |
I've run into what seems to me to be a pretty serious issue. I've got devise as well as device_token_auth setup side-by-side, as well as ng-token-auth for the ionic front-end. When logging in/out with different users everything is working fine as long as I login using regular devise or in my ionic project with ng-token-auth in a regular browser (localStorage is used for storing the tokens).
However, when running the ionic project on an android phone, when I log in through a first user and then out, then login with a second user I still see the first user's data. Looking at the rails logs I see that for some requests actually the id of the previous user is used when using current_user.id in the query.
First the user logs in and the correct user id is select (id=20), so far so good:
Then immediately after login, ui-router invokes another state and another request is made using this query in the controller with current_user.id:
This triggers the following query for getting the current_user details:
As you can see here somehow the results for another user with id=18 are returned instead of the expected details for user with id=20!!
The strange thing is that in parallel to this query I update the account with a token I received from the ionic platform that does use the right user id:
Even stranger to me is that, when I look at the request headers that the ionic app is sending to devise_token_auth for both these last two queries, that the client and access-token headers are exactly the same. I understand that this is to be expected due to the batch_request_buffer_throttle setting. However, I really don't understand how two queries with the exact same tokens can result in a different user id on the server side. BTW these tokens are the ones that were sent in the response to the sign_in request.
I will continue to try and research this myself but I would love some guidance with what seems to me to be a serious bug.
Thanks!
The text was updated successfully, but these errors were encountered: