Module: UserAuth::Web::Helpers
- Defined in:
- lib/user_auth/web/helpers.rb
Instance Method Summary collapse
- #build_jwt(data) ⇒ Object
- #current_user ⇒ Object
- #deliver_email(options) ⇒ Object
- #json(data) ⇒ Object
- #json_user_token(user) ⇒ Object
- #params ⇒ Object
- #warden ⇒ Object
Instance Method Details
#build_jwt(data) ⇒ Object
33 34 35 36 |
# File 'lib/user_auth/web/helpers.rb', line 33 def build_jwt(data) exp = Time.now.to_i + UserAuth.configuration.jwt_exp Token.new.create(data.merge(exp: exp)) end |
#current_user ⇒ Object
8 9 10 |
# File 'lib/user_auth/web/helpers.rb', line 8 def current_user @current_user ||= UserAuth::Models::User.with_pk!(warden.user.user_id) end |
#deliver_email(options) ⇒ Object
16 17 18 |
# File 'lib/user_auth/web/helpers.rb', line 16 def deliver_email() UserAuth.configuration.deliver_mail.call() end |
#json(data) ⇒ Object
20 21 22 23 |
# File 'lib/user_auth/web/helpers.rb', line 20 def json(data) content_type(:json) JSON.dump(data) end |
#json_user_token(user) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/user_auth/web/helpers.rb', line 25 def json_user_token(user) json( token_type: "Bearer", token: build_jwt(user.to_json), refresh_token: user.refresh_token! ) end |
#params ⇒ Object
12 13 14 |
# File 'lib/user_auth/web/helpers.rb', line 12 def params super.symbolize_keys.with_indifferent_access end |
#warden ⇒ Object
4 5 6 |
# File 'lib/user_auth/web/helpers.rb', line 4 def warden env["warden"] end |