Class: Mints::BaseController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/mints/controllers/base_controller.rb

Instance Method Summary collapse

Instance Method Details

#mints_contact_login(email, password) ⇒ Object

Mints Contact Login.

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

[View source]

22
23
24
25
26
27
28
29
# 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']
    # Set a permanent cookie with the session token
    cookies.permanent[:mints_contact_session_token] = session_token
end

#mints_contact_logoutObject

Mints Contact Logout.

Destroy session from mints.cloud and delete local session cookie

[View source]

34
35
36
37
38
39
# File 'lib/mints/controllers/base_controller.rb', line 34

def mints_contact_logout
    # Logout from mints
    @mints_contact.logout
    # Delete local cookie
    cookies.delete(:mints_contact_session_token)
end

#mints_contact_signed_in?Boolean

Returns:

  • (Boolean)
[View source]

8
9
10
11
12
13
14
15
16
17
# File 'lib/mints/controllers/base_controller.rb', line 8

def mints_contact_signed_in?
    # Check status in mints
    response = @mints_contact.status
    status = response['success'] ? response['success'] : false
    unless status
      # if mints response is negative delete the session cookie
      cookies.delete(:mints_contact_session_token)
    end
    return status
end