Skip to content

Commit

Permalink
Use secret_key_base from ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
Navaneeth-pk committed Apr 16, 2021
1 parent 9a33306 commit a5d0cfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/json_web_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ class JsonWebToken
class << self
def encode(payload, exp = 24.hours.from_now)
payload[:exp] = exp.to_i
JWT.encode(payload, Rails.application.credentials.secret_key_base)
JWT.encode(payload, ENV.fetch("SECRET_KEY_BASE"))
end

def decode(token)
body = JWT.decode(token, Rails.application.credentials.secret_key_base)[0]
body = JWT.decode(token, ENV.fetch("SECRET_KEY_BASE"))[0]
HashWithIndifferentAccess.new body
rescue
nil
Expand Down

0 comments on commit a5d0cfd

Please sign in to comment.