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



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

def authorized
  redirect_to  unless logged_in?
end

#current_ownerObject



16
17
18
# File 'app/controllers/cl_wiki/application_controller.rb', line 16

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

#current_userObject



10
11
12
13
14
# File 'app/controllers/cl_wiki/application_controller.rb', line 10

def current_user
  User.find(session[:username])&.tap do |user|
    user.cached_encryption_key = Base64.decode64(session[:encryption_key])
  end
end

#initialize_indexObject



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

def initialize_index
  ClWiki::MemoryIndexer.instance(page_owner: current_owner)
end

#logged_in?Boolean

Returns:

  • (Boolean)


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

def logged_in?
  !current_user.nil?
end