Method: ContactAuthHelper#mints_contact_magic_link_login
- Defined in:
- lib/mints/helpers/contact_auth_helper.rb
#mints_contact_magic_link_login(hash, redirect_in_error = false) ⇒ Object
Mints contact Login.
Starts a contact session in mints.cloud and set a session cookie
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mints/helpers/contact_auth_helper.rb', line 20 def mints_contact_magic_link_login(hash, redirect_in_error = false) # Login in mints response = @mints_contact.magic_link_login(hash) if response['data'] # Get session token from response session_token = response['data']['session_token'] id_token = response['data']['contact']['contact_token'] ? response['data']['contact']['contact_token'] : response['data']['contact']['id_token'] # Set a permanent cookie with the session token .permanent[:mints_contact_session_token] = { value: session_token, secure: true, httponly: true } .permanent[:mints_contact_id] = { value: id_token, secure: true, httponly: true } @contact_token = id_token redirect_to response['data']['redirect_url'] ? response['data']['redirect_url'] : '/' if redirect_in_error else redirect_to '/' if redirect_in_error end end |