I have a few urls in my app:
/
- Homepage (no auth required)
/login
- Login Form (no auth required)
/admin
- Displays dashboard for the logged in user (auth required)
If an unauthenticated user visits /admin
then they are redirected (302 See Other) to /login
. When the user logs in then they are redirected to /admin
(302 See Other).
In my Hotwire native app (iOS) I want two things to happen.
When the unauthenticated user visits /admin
I want a login modal to appear. Currently a new screen slides in and the request is made, the redirect is followed to /login
.
If I add a path configuration to load /login
in a modal a modal appears on top of the current view (which also contains the /login
html):
{
"settings": {},
"rules": [
{
"patterns": ["/login"],
"properties": {
"context": "modal"
}
}
]
}
Is is possible to configure the server response / iOS app somehow to catch the 302 and not follow the redirect?
Do I need to add conditional logic in the controller to return a 401 unauthorised for the iOS app and handle that differently?
I don’t want to implement a native iOS authentication login pattern and jwt tokens.