diff options
author | re4k <re4k@re4k.info> | 2013-05-06 13:34:09 +0900 |
---|---|---|
committer | re4k <re4k@re4k.info> | 2013-05-06 13:34:09 +0900 |
commit | af3990115b393efed9bf1c90fdb6648e3a1e1ef0 (patch) | |
tree | 87cc8cf10091bc094b68fe75ea7202615848acca /app/controllers/application_controller.rb | |
parent | f5cb96795352731404ce4ea15e707ebcb55053a9 (diff) | |
download | aclog-af3990115b393efed9bf1c90fdb6648e3a1e1ef0.tar.gz |
add protected user support (temp)
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 912bbdd..0ed7cf0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- class ApplicationController < ActionController::Base protect_from_forgery - before_filter :set_format + before_filter :set_format, :check_session after_filter :xhtml protected @@ -13,6 +13,21 @@ class ApplicationController < ActionController::Base end end + def authorized_to_show?(user) + case + when (not user.protected?) + true + when (not session[:user_id]) + false + when user.id == session[:user_id] + true + when session[:account].following?(user) + true + else + false + end + end + private def set_format unless [:json, :html].include?(request.format.to_sym) @@ -20,6 +35,12 @@ class ApplicationController < ActionController::Base end end + def check_session + if (session[:user_id] || session[:account]) and not (session[:user_id] && session[:account]) + reset_session + end + end + def xhtml if request.format == :html response.content_type = "application/xhtml+xml" |