Redirect suspended users to an information page

If the current session is for a logged in user and that user has
been suspended then log them out and redirect them to a page
explaining that their account has been suspended.
This commit is contained in:
Tom Hughes 2010-05-07 10:00:24 +01:00
parent 7211872790
commit 9230721a1f
4 changed files with 27 additions and 1 deletions

View file

@ -8,7 +8,14 @@ class ApplicationController < ActionController::Base
def authorize_web
if session[:user]
@user = User.find(session[:user], :conditions => {:status => ["active", "confirmed"]})
@user = User.find(session[:user], :conditions => {:status => ["active", "confirmed", "suspended"]})
if @user.status == "suspended"
session[:user] = nil
session_expires_automatically
redirect_to :controller => "user", :action => "suspended"
end
elsif session[:token]
@user = User.authenticate(:token => session[:token])
session[:user] = @user.id

View file

@ -0,0 +1,5 @@
<% @title = t "user.suspended.title" %>
<h1><%= t "user.suspended.heading" %></h1>
<%= t "user.suspended.body", :webmaster => "webmaster@openstreetmap.org" %>

View file

@ -1655,6 +1655,19 @@ en:
confirm: Confirm Selected Users
hide: Hide Selected Users
empty: No matching users found
suspended:
title: Account Suspended
heading: Account Suspended
body: |
<p>
Sorry, your account has been automatically suspended due to
suspicious activity.
</p>
<p>
This decision will be reviewed by an administrator shortly, or
you may contact the <a href="mailto:{{webmaster}}">webmaster</a> if
you wish to discuss this.
</p>
user_role:
filter:
not_an_administrator: "Only administrators can perform user role management, and you are not an administrator."

View file

@ -104,6 +104,7 @@ ActionController::Routing::Routes.draw do |map|
map.connect '/user/go_public', :controller => 'user', :action => 'go_public'
map.connect '/user/reset-password', :controller => 'user', :action => 'reset_password'
map.connect '/user/forgot-password', :controller => 'user', :action => 'lost_password'
map.connect '/user/suspended', :controller => 'user', :action => 'suspended'
map.connect '/index.html', :controller => 'site', :action => 'index'
map.connect '/edit.html', :controller => 'site', :action => 'edit'