Project

General

Profile

« Previous | Next » 

Revision a579432b

Added by Marc Dequènes almost 13 years ago

  • ID a579432b8465d28632aa81b55adb93f2a5f2e439

[fix/evol] forgot new files in the previous commits and check admin status to access user management

View differences:

app/controllers/application.rb
34 34
  end
35 35

  
36 36
  def login_required
37
    if session[:user_id]
38
      return true
39
    end
37
    return true if session[:user_id]
38

  
40 39
    flash[:warning] = _('Please login to continue')
41 40
    session[:return_to] = request.request_uri
42 41
    redirect_to :controller => "/logon", :action => "login"
43 42
    return false
44 43
  end
45 44

  
45
  def admin_required
46
    return true if login_required and current_user.admin
47

  
48
    @reject_reason = "You are not an Admin !"
49
    render :template => "common/403", :layout => ! request.xhr?, :status => :forbidden
50
    return false
51
  end
52

  
46 53
  def current_user
47 54
    @current_user ||= ((session[:user_id] && User.find_by_id(session[:user_id])) || nil)
48 55
  end

Also available in: Unified diff