Sha256: 18ec632cefa001353484b1d294ea6cc29c19f687733b005678b897549cccdc37

Contents?: true

Size: 1.08 KB

Versions: 16

Compression:

Stored size: 1.08 KB

Contents

require 'haml'
require 'sinatra/base'
require 'sinatra/support'

module Classiccms
  class ApplicationController < Sinatra::Base
    include  Classiccms::Routing
    register Sinatra::MultiRender
    helpers  Classiccms::Helpers

    set :multi_views,   [ File.join(Dir.pwd, 'views')]
    set :root, Dir.pwd
    set :public_folder, Proc.new { File.join(Dir.pwd, 'public') }
    set :session_secret, '427a474a206b616e5c4f2a4f3c7d2d517e2a564e21556e24593363253e'

    enable :sessions

    before do
      @user = User.find(session[:user_id]) if session[:user_id] != nil
    end

    get '/login' do
      show :login, views: File.join(Classiccms::ROOT, 'views/cms')
    end
    post '/login' do
      user = User.where(:username => params[:username], :password => params[:password]).first
      if user != nil
        session[:user_id] = user.id
        redirect to(params[:correct] != nil ? params[:correct] : '/')
      else
        redirect to(params[:incorrect] != nil ? params[:incorrect] : '/login')
      end
    end
    get '/logout' do
      session[:user_id] = nil
      redirect '/'
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
classiccms-0.5.2 lib/classiccms/controllers/application.rb
classiccms-0.5.1 lib/classiccms/controllers/application.rb
classiccms-0.5.0 lib/classiccms/controllers/application.rb
classiccms-0.4.2 lib/classiccms/controllers/application.rb
classiccms-0.4.1 lib/classiccms/controllers/application.rb
classiccms-0.4.0 lib/classiccms/controllers/application.rb
classiccms-0.3.9 lib/classiccms/controllers/application.rb
classiccms-0.3.8 lib/classiccms/controllers/application.rb
classiccms-0.3.7 lib/classiccms/controllers/application.rb
classiccms-0.3.6 lib/classiccms/controllers/application.rb
classiccms-0.3.5 lib/classiccms/controllers/application.rb
classiccms-0.3.4 lib/classiccms/controllers/application.rb
classiccms-0.3.3 lib/classiccms/controllers/application.rb
classiccms-0.3.2 lib/classiccms/controllers/application.rb
classiccms-0.3.1 lib/classiccms/controllers/application.rb
classiccms-0.3.0 lib/classiccms/controllers/application.rb