token去除session验证
This commit is contained in:
parent
9a4dafbce5
commit
e1d0dc4661
|
@ -4,7 +4,7 @@ class OauthController < ApplicationController
|
|||
include ApplicationHelper
|
||||
|
||||
before_filter :user_setup
|
||||
before_filter :require_login, only: [:authorize, :token]
|
||||
before_filter :require_login, only: [:authorize]
|
||||
|
||||
|
||||
skip_before_filter :verify_authenticity_token, only: [:token]
|
||||
|
@ -49,7 +49,8 @@ class OauthController < ApplicationController
|
|||
## 检查通过,生成code
|
||||
oauth = Oauth.create!(client_id: config.client_id,
|
||||
client_secret: config.client_secret,
|
||||
redirect_uri: config.redirect_uri
|
||||
redirect_uri: config.redirect_uri,
|
||||
user_id: User.current.id
|
||||
)
|
||||
code = oauth.gen_code
|
||||
|
||||
|
@ -110,7 +111,7 @@ class OauthController < ApplicationController
|
|||
|
||||
## 生成 token
|
||||
#
|
||||
oauth.gen_token(User.current.id)
|
||||
oauth.gen_token
|
||||
|
||||
oauth.reload
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class Oauth < ActiveRecord::Base
|
|||
code
|
||||
end
|
||||
|
||||
def gen_token(user_id)
|
||||
def gen_token
|
||||
access_token = Digest::MD5.hexdigest "#{Time.now}-#{Random.new_seed}"
|
||||
refresh_token = Digest::MD5.hexdigest "#{Random.new_seed}-#{Time.now}-#{Random.new_seed}"
|
||||
|
||||
|
@ -22,7 +22,6 @@ class Oauth < ActiveRecord::Base
|
|||
refresh_token: refresh_token,
|
||||
token_created_at: Time.now.to_i,
|
||||
token_expires_in: Time.now.to_i + 24*60*60,
|
||||
user_id: user_id
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue