0
在我的Rails應用程序中,在成功使用設計登錄後,我想調用返回令牌的外部服務。我如何將它傳遞給客戶端以保持它(例如在localStorage中)?在設計身份驗證後在客戶端存儲數據
class Users::SessionsController < Devise::SessionsController
def create
super
login_to_chat #successful login
end
def login_to_chat
uri = URI('https://xxxxxx.ws/authenticate')
https = Net::HTTP.new(uri.host,uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/json'
req.body = params[:user].slice(:username,:password).to_json
res = https.request(req)
if res.kind_of? Net::HTTPSuccess
json = JSON.parse(res.body)
# how can I pass json['public_token'] to the client?
end
end
end
TNX HIEU。即使我沒有指定這是我需要的:多種選擇來更好地評估安全問題。 – masciugo