Module: Auth1::SessionsHelper

Defined in:
app/helpers/auth1/sessions_helper.rb

Instance Method Summary collapse

Instance Method Details

#logged_in?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/helpers/auth1/sessions_helper.rb', line 61

def logged_in?
  session['userinfo'].present?
end

#logged_out?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/helpers/auth1/sessions_helper.rb', line 65

def logged_out?
  !logged_in?
end

#login_button(name = 'Login', options = nil, html_options = nil, &block) ⇒ Object



9
10
11
12
13
14
# File 'app/helpers/auth1/sessions_helper.rb', line 9

def (name = 'Login', options = nil, html_options = nil, &block)
  options ||= 
  html_options ||= {}
  html_options[:method] = :post
  button_to(name, options, html_options, &block)
end


35
36
37
38
39
40
# File 'app/helpers/auth1/sessions_helper.rb', line 35

def (name = 'Login', options = nil, html_options = nil, &block)
  options ||= 
  html_options ||= {}
  html_options[:method] = :post
  link_to(name, options, html_options, &block)
end

#login_or_logout_button(name = %w[Login Logout],, options = [nil, nil], html_options = [nil, nil], &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/auth1/sessions_helper.rb', line 23

def (name = %w[Login Logout], options = [nil, nil], html_options = [nil, nil], &block)
  if logged_in?
    logout_html_options = html_options[1] || {}
    logout_html_options[:method] = :get
    logout_button(name[1], options[1], logout_html_options, &block)
  else
     = html_options[0] || {}
    [:method] = :post
    (name[0], options[0], , &block)
  end
end


49
50
51
52
53
54
55
56
57
58
59
# File 'app/helpers/auth1/sessions_helper.rb', line 49

def (name = %w[Login Logout], options = [nil, nil], html_options = [nil, nil], &block)
  if logged_in?
    logout_html_options = html_options[1] || {}
    logout_html_options[:method] = :get
    logout_link(name[1], options[1], logout_html_options, &block)
  else
     = html_options[0] || {}
    [:method] = :post
    (name[0], options[0], , &block)
  end
end

#login_pathObject



5
6
7
# File 'app/helpers/auth1/sessions_helper.rb', line 5

def 
  '/auth/auth0'
end

#logout_button(name = 'Logout', options = nil, html_options = nil, &block) ⇒ Object



16
17
18
19
20
21
# File 'app/helpers/auth1/sessions_helper.rb', line 16

def logout_button(name = 'Logout', options = nil, html_options = nil, &block)
  options ||= auth1.logout_path
  html_options ||= {}
  html_options[:method] = :get
  button_to(name, options, html_options, &block)
end


42
43
44
45
46
47
# File 'app/helpers/auth1/sessions_helper.rb', line 42

def logout_link(name = 'Logout', options = nil, html_options = nil, &block)
  options ||= auth1.logout_path
  html_options ||= {}
  html_options[:method] = :get
  link_to(name, options, html_options, &block)
end