Sha256: 36accd589a05e15df884c0234ff03d0b5b4818d9cd720b844e14a1550dc83239

Contents?: true

Size: 828 Bytes

Versions: 3

Compression:

Stored size: 828 Bytes

Contents

# frozen_string_literal: true

module ClWiki
  class SessionsController < ApplicationController
    before_action :skip_all_if_not_using_authentication
    skip_before_action :authorized, only: %i[new create]
    skip_before_action :initialize_index, only: %i[new create]

    def new
    end

    def create
      @user = User.find(params[:username])
      password = params[:password]
      if @user&.username == $wiki_conf.owner && @user&.authenticate(password)
        session[:username] = @user.username
        session[:encryption_key] = Base64.encode64(@user.derive_encryption_key(password))
        redirect_to root_url
      else
        redirect_to login_url
      end
    end

    private

    def skip_all_if_not_using_authentication
      redirect_to root_url unless $wiki_conf.use_authentication
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clwiki-3.0.2 app/controllers/cl_wiki/sessions_controller.rb
clwiki-3.0.1 app/controllers/cl_wiki/sessions_controller.rb
clwiki-3.0.0 app/controllers/cl_wiki/sessions_controller.rb