From: Steve Coast Date: Sat, 7 Apr 2007 10:28:38 +0000 (+0000) Subject: throw user to login if trying to edit without logging in X-Git-Tag: live~8572 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/3789c7b592280bde502a377c5d7c31108d90db82?hp=4f826acfca0ede6b7d4868e8bb45a608c44582ce throw user to login if trying to edit without logging in --- diff --git a/app/controllers/application.rb b/app/controllers/application.rb index a4f65cd54..6520e027b 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -6,6 +6,10 @@ class ApplicationController < ActionController::Base @user = User.find_by_token(session[:token]) end + def require_user + redirect_to :controller => 'user', :action => 'login' unless @user + end + def authorize(realm='Web Password', errormessage="Could't authenticate you") username, passwd = get_auth_data # parse from headers # authenticate per-scheme diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 380c41436..f4ccd3c74 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -1,6 +1,6 @@ class SiteController < ApplicationController before_filter :authorize_web - + before_filter :require_user, :only => [:edit] def index end