Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lynndylanhurley committed Oct 2, 2014
1 parent b5cc06b commit 5a3a0eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ def omniauth_success
provider: auth_hash['provider']
}).first_or_initialize

# create client id
# create token info
@client_id = SecureRandom.urlsafe_base64(nil, false)
@token = SecureRandom.urlsafe_base64(nil, false)
@expiry = (Time.now + DeviseTokenAuth.token_lifespan).to_i

@auth_origin_url = generate_url(omniauth_params['auth_origin_url'], {
token: @token,
client_id: @client_id,
uid: @user.uid
uid: @user.uid,
expiry: @expiry
})

# set crazy password for new oauth users. this is only used to prevent
Expand All @@ -45,7 +47,7 @@ def omniauth_success

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

# sync user info with provider, update/generate auth token
Expand Down
3 changes: 2 additions & 1 deletion app/views/devise_token_auth/omniauth_success.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

"auth_token": "<%= @token %>",
"message": "deliverCredentials",
"client_id": "<%= @client_id %>"
"client_id": "<%= @client_id %>",
"expiry": "<%= @expiry %>"

0 comments on commit 5a3a0eb

Please sign in to comment.