Skip to content

Commit

Permalink
Merge pull request #1 from rootstrap/fix/tokens_as_string_issue
Browse files Browse the repository at this point in the history
Fix for stringified token issue on sign in
  • Loading branch information
diebarral authored Sep 14, 2017
2 parents 7f61b60 + 430d463 commit c1bb712
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/devise_token_auth/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def create
@client_id = SecureRandom.urlsafe_base64(nil, false)
@token = SecureRandom.urlsafe_base64(nil, false)

# Next line is necessary for the exceptional cases in which the tokens are stored as strings in the database.
@resource.tokens = JSON.parse(@resource.tokens) if @resource.tokens.is_a? String

@resource.tokens[@client_id] = {
token: BCrypt::Password.create(@token),
expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
Expand Down

0 comments on commit c1bb712

Please sign in to comment.