Module: AppRail::Airtable::Authenticatable::InstanceMethods
- Defined in:
- lib/app_rail/airtable/authenticatable.rb
Instance Method Summary collapse
- #ensure_access_token! ⇒ Object
- #oauth_session ⇒ Object
- #password_hash ⇒ Object
- #valid_password?(password) ⇒ Boolean
Instance Method Details
#ensure_access_token! ⇒ Object
69 70 71 72 73 74 |
# File 'lib/app_rail/airtable/authenticatable.rb', line 69 def ensure_access_token! unless self['Access Token'] self['Access Token'] = User.next_access_token save end end |
#oauth_session ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/app_rail/airtable/authenticatable.rb', line 58 def oauth_session ensure_access_token! { access_token: self['Access Token'], scope: :user, token_type: :bearer, expires_in: 31_536_000 # 1 year } end |
#password_hash ⇒ Object
54 55 56 |
# File 'lib/app_rail/airtable/authenticatable.rb', line 54 def password_hash self['Password Hash'] end |
#valid_password?(password) ⇒ Boolean
50 51 52 |
# File 'lib/app_rail/airtable/authenticatable.rb', line 50 def valid_password?(password) BCrypt::Password.new(password_hash) == password end |