Merged r9417 from trunk (#10664).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9455 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-04-20 07:45:33 +00:00
parent da1a3449ce
commit e5802895ce
14 changed files with 133 additions and 8 deletions
-8
View File
@@ -131,14 +131,6 @@ class AccountController < ApplicationController
private
def logout_user
if User.current.logged?
cookies.delete :autologin
Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
self.logged_user = nil
end
end
def authenticate_user
if Setting.openid? && using_open_id?
open_id_authenticate(params[:openid_url])
@@ -126,6 +126,15 @@ class ApplicationController < ActionController::Base
end
end
# Logs out current user
def logout_user
if User.current.logged?
cookies.delete :autologin
Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
self.logged_user = nil
end
end
# check if login is globally required to access the application
def check_if_login_required
# no check needed if user is already logged in
+18
View File
@@ -65,6 +65,24 @@ class MyController < ApplicationController
end
end
# Destroys user's account
def destroy
@user = User.current
unless @user.own_account_deletable?
redirect_to :action => 'account'
return
end
if request.post? && params[:confirm]
@user.destroy
if @user.destroyed?
logout_user
flash[:notice] = l(:notice_account_deleted)
end
redirect_to home_path
end
end
# Manage user's password
def password
@user = User.current
+6
View File
@@ -486,6 +486,12 @@ class User < Principal
allowed_to?(action, nil, options.reverse_merge(:global => true), &block)
end
# Returns true if the user is allowed to delete his own account
def own_account_deletable?
Setting.unsubscribe? &&
(!admin? || User.active.first(:conditions => ["admin = ? AND id <> ?", true, id]).present?)
end
safe_attributes 'login',
'firstname',
'lastname',
+3
View File
@@ -3,6 +3,9 @@
<p><%=l(:field_login)%>: <strong><%= link_to_user(@user, :format => :username) %></strong><br />
<%=l(:field_created_on)%>: <%= format_time(@user.created_on) %></p>
<% if @user.own_account_deletable? %>
<p><%= link_to(l(:button_delete_my_account), {:action => 'destroy'}, :class => 'icon icon-del') %></p>
<% end %>
<h4><%= l(:label_feeds_access_key) %></h4>
+11
View File
@@ -0,0 +1,11 @@
<h2><%=l(:label_confirmation)%></h2>
<div class="warning">
<p><%= simple_format l(:text_account_destroy_confirmation)%></p>
<p>
<% form_tag({}) do %>
<label><%= check_box_tag 'confirm', 1 %> <%= l(:general_text_Yes) %></label>
<%= submit_tag l(:button_delete_my_account) %> |
<%= link_to l(:button_cancel), :action => 'account' %>
<% end %>
</p>
</div>
@@ -10,6 +10,8 @@
[l(:label_registration_manual_activation), "2"],
[l(:label_registration_automatic_activation), "3"]] %></p>
<p><%= setting_check_box :unsubscribe %></p>
<p><%= setting_text_field :password_min_length, :size => 6 %></p>
<p><%= setting_check_box :lost_password, :label => :label_password_lost %></p>