diff options
author | rhenium <rhenium@rhe.jp> | 2015-03-01 16:37:46 +0900 |
---|---|---|
committer | rhenium <rhenium@rhe.jp> | 2015-03-01 16:37:46 +0900 |
commit | 8d0a951cd82e1cc7316a52164ebdafcd1dea9107 (patch) | |
tree | 6fec8741e5b0b49e2d3a62a12bcc29738a1420c3 | |
parent | 5caac1ac5e940bff8a7953ae92eaad2f9790095d (diff) | |
download | aclog-8d0a951cd82e1cc7316a52164ebdafcd1dea9107.tar.gz |
api: return session cookie
-rw-r--r-- | app/api/api.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/api/api.rb b/app/api/api.rb index 960a450..8dcb7be 100644 --- a/app/api/api.rb +++ b/app/api/api.rb @@ -20,10 +20,17 @@ class Api < Grape::API helpers TwitterOauthEchoAuthentication helpers do + def session + env[Rack::Session::Abstract::ENV_SESSION_KEY] + end + def current_user @_current_user ||= begin - if headers["X-Verify-Credentials-Authorization"] + if session.key?(:api_user_id) + User.find(session[:api_user_id]) + elsif headers["X-Verify-Credentials-Authorization"] user_id = authenticate_with_twitter_oauth_echo + session[:api_user_id] = user_id User.find(user_id) end end |