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