0
damuz91
6y

They asked me to build a small website they will embed in a native application with some web wrapper in Android and iOS.

But also asked me to build a login web service that will return a JWT. Done.

They want to do a native code login form that opens up the web wrapper with my small website already logged in using the login web service.

I have no idea how to proceed in the backend.

At first i tried using postman with a POST request to the sessions/sign_in route and sending a form with the authenticity token and the email and password; but CSRF stopped me. I don't want to turn it off because of reasons.

Now i am wondering how to use this JWT to generate a cookie with a session inside it that they can use in the web wrapper.

Any help would be appreciated :)

Comments
  • 1
    No useful advice (because my advice would be "don't do that")
  • 0
    @monkeyboy i'm with you. But i got to do this for a presentation :(
  • 0
    Update: I think i got it.
    In my api endpoint i should simply use:

    session[:user_id] = user.id

    and that would return to the requested a cookie that they can use in the web wrapper i guess.

    Got to love rails
  • 0
    Final update:
    I finally made it by adding:
    sign_in user

    So it sends the set-cookie with the request.

    Loving rails!
Add Comment