Closed samu closed 3 years ago
This is tricky because for some APIs, you won’t even use the session but just return the token, so you would reuse very little of this function.
So generally speaking we prefer to keep the code simple rather than prepare it for all possible scenarios, because there are just too many to predict. Thanks!
The standard
UserSessionController.create
looks like this:I wanted to create a log-in endpoint which can be used to log in via an Ajax request. The main difference would be that it doesn't redirect and instead returns a
200
status code and a JSON compatible payload:The problem is, that
UserAuth.log_in_user
does aredirect
right at the end of it's processing:Now i'm wondering if this
redirect
really belongs into theUserAuth
module. One could argue that the decision to redirect should go into the respective controller.I of course understand that i could simply tweak the generated code, but i think it would be optimal if i had to do as little changes to the generated code as possible.