Class: ClWiki::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- ClWiki::ApplicationController
show all
- Defined in:
- app/controllers/cl_wiki/application_controller.rb
Instance Method Summary
collapse
Instance Method Details
#authorized ⇒ Object
29
30
31
|
# File 'app/controllers/cl_wiki/application_controller.rb', line 29
def authorized
redirect_to login_url unless logged_in?
end
|
#current_owner ⇒ Object
21
22
23
|
# File 'app/controllers/cl_wiki/application_controller.rb', line 21
def current_owner
current_user || ClWiki::PublicUser.new
end
|
#current_user ⇒ Object
15
16
17
18
19
|
# File 'app/controllers/cl_wiki/application_controller.rb', line 15
def current_user
User.find(session[:username])&.tap do |user|
user.cached_encryption_key = Base64.decode64(session[:encryption_key])
end
end
|
#expire_old_session ⇒ Object
11
12
13
|
# File 'app/controllers/cl_wiki/application_controller.rb', line 11
def expire_old_session
reset_session if session[:expire_at]&.< Time.now
end
|
#initialize_index ⇒ Object
33
34
35
|
# File 'app/controllers/cl_wiki/application_controller.rb', line 33
def initialize_index
ClWiki::MemoryIndexer.instance(page_owner: current_owner)
end
|
#logged_in? ⇒ Boolean
25
26
27
|
# File 'app/controllers/cl_wiki/application_controller.rb', line 25
def logged_in?
!current_user.nil?
end
|