Project

General

Profile

« Previous | Next » 

Revision d0ff9068

Added by Marc Dequènes over 15 years ago

  • ID d0ff90685657026f9316e7455a54dc35690a97eb

[evol] created a simple logon system, protected admin pages, and added a logon indicator/link (no user management yet, only a deadend entry in the menu if admin)

View differences:

app/controllers/application.rb
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => '86f01f14fc184c81bf152965a2bccb88'
filter_parameter_logging :password
init_gettext MyCyma::Info::app_name
def initialize
......
render :template => "common/404", :layout => ! request.xhr?, :status => :not_found
return false
end
def login_required
if session[:user_id]
return true
end
flash[:warning] = _('Please login to continue')
session[:return_to] = request.request_uri
redirect_to :controller => "/logon", :action => "login"
return false
end
def current_user
@current_user ||= ((session[:user_id] && User.find_by_id(session[:user_id])) || nil)
end
def redirect_to_stored
if return_to = session[:return_to]
session[:return_to] = nil
redirect_to(return_to)
else
redirect_to :controller => 'welcome', :action => 'index'
end
end
end

Also available in: Unified diff