Class: Bookends::ApplicationHelper::GlostickUserExtractor

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/bookends/application_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cookies) ⇒ GlostickUserExtractor

Returns a new instance of GlostickUserExtractor.



59
60
61
62
# File 'app/helpers/bookends/application_helper.rb', line 59

def initialize(cookies)
  @secret = ENV['SESSION_COOKIE_SECRET_PRIMARY'] || ENV['SESSION_COOKIE_SECRET_SECONDARY']
  @token  = CGI::unescape(cookies[:heroku_user_session]) if cookies[:heroku_user_session]
end

Instance Attribute Details

#secretObject (readonly)

Returns the value of attribute secret.



56
57
58
# File 'app/helpers/bookends/application_helper.rb', line 56

def secret
  @secret
end

#tokenObject (readonly)

Returns the value of attribute token.



56
57
58
# File 'app/helpers/bookends/application_helper.rb', line 56

def token
  @token
end

Instance Method Details

#userObject



64
65
66
67
68
69
70
71
72
73
74
# File 'app/helpers/bookends/application_helper.rb', line 64

def user
  session_info = decrypt_session_cookie
  if session_info && session_info['user']
    session_info['user']
  else
    {
      'email' => '',
      'full_name' => ''
    }
  end
end