-
Notifications
You must be signed in to change notification settings - Fork 223
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
Elixir.FunctionClauseError on Coherence.update_user_logins function #384
Comments
I agree. First, there is no reason to call On one hand, I like the idea of graceful fail, but on the other hand, the exception is showing you that you are doing something wrong (can't update logged out user). So, in a sense, the exception is catching a problem in your application. If we were to fail gracefully, you may never know that the function failed. Perhaps the way to solve this is to create a second |
Is there a way to tell if a user is logged in? |
Hi @smpallen99, Thanks a lot for your reply. I see what you are saying that we should not try updating logged out users and also the fact that it sort of tells me it is not expected to be used that way. However, I don't think we're loosing much by making it to fail gracefully when Coherence is not even telling you why it is happening clearly. I think it raises an exception more by accident than by design. I know it is for updating cache for logged in users, but we're not updating current user's data so more graceful response would be desirable instead of having to check the existence of logged in user's session before. I'm not sure if I'd ever want it to throw an exception for this even if the exception message was clearer. Probably returning an error tuple would be sufficient in case someone wants to handle it differently. Also, I'm not sure if there is any method for checking other user's login status though. I guess we can query the database but I'd much rather have it ignore logged out user than querying the db to figure it out. There is also a chance of this exception happening within that split second if the user logs out so I don't think that's the exception free solution either. |
Hi,
I'm just wondering if this is something that needs to be fixed or I'm using it wrong.
I'm not exactly sure how this is happening as I don't see the sender of this request, but I'm getting this exception.
We're calling
Coherence.update_user_logins(user)
when admin updates user's record in order to make sure the logged in users credentials gets updated as well.I think exception is happening due to the fact that the user is not logged in at the time of this update as this code below doesn't seem to handle signed out users.
https://github.com/smpallen99/coherence/blob/master/lib/coherence/plugs/authorization/credential_store/server.ex#L94
I'm wondering if we need to add extra match something like
fn nil -> nil
to make sure we gracefully handle cases where the user data doesn't present on the GenServer.Please let me know if this seems like a way to go, I'll submit a PR for that.
Thanks,
David
The text was updated successfully, but these errors were encountered: