Method: Mints::BaseController#mints_contact_login

Defined in:
lib/mints/controllers/base_controller.rb

#mints_contact_login(email, password) ⇒ Object

Mints Contact Login.

Starts a contact session in mints.cloud and set a session cookie


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mints/controllers/base_controller.rb', line 22

def (email, password)
    # Login in mints
    response = @mints_contact.(email, password)
    # Get session token from response
    session_token = response['session_token']
    id_token = response['contact']['contact_token'] ? response['contact']['contact_token'] : response['contact']['id_token']
    # Set a permanent cookie with the session token
    cookies.permanent[:mints_contact_session_token] = { value: session_token, secure: true, httponly: true }
    cookies.permanent[:mints_contact_id] = { value: id_token, secure: true, httponly: true }
    @contact_token = id_token
end