Class: ClWiki::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/cl_wiki/application_controller.rb

Direct Known Subclasses

PageController, SessionsController

Instance Method Summary collapse

Instance Method Details

#authorizedObject



29
30
31
# File 'app/controllers/cl_wiki/application_controller.rb', line 29

def authorized
  redirect_to  unless logged_in?
end

#current_ownerObject



21
22
23
# File 'app/controllers/cl_wiki/application_controller.rb', line 21

def current_owner
  current_user || ClWiki::PublicUser.new
end

#current_userObject



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_sessionObject



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_indexObject



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

Returns:

  • (Boolean)


25
26
27
# File 'app/controllers/cl_wiki/application_controller.rb', line 25

def logged_in?
  !current_user.nil?
end