Feature #348: Change Email

This commit is contained in:
mblog 2010-12-13 22:14:25 +01:00 committed by Marc Bertram
parent f861955d80
commit d0355fdd43
4 changed files with 18 additions and 3 deletions

View file

@ -21,6 +21,7 @@ class UsersController < ApplicationController
params[:user].delete(:password) if params[:user][:password].blank?
params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
params[:user].delete(:language) if params[:user][:language].blank?
params[:user].delete(:email) if params[:user][:email].blank?
# change email notifications
if params[:user][:disable_mail]
@ -39,6 +40,13 @@ class UsersController < ApplicationController
else
flash[:error] = I18n.t 'users.update.language_not_changed'
end
# change email
elsif params[:user][:email]
if @user.update_attributes(:email => params[:user][:email])
flash[:notice] = I18n.t 'users.update.email_changed'
else
flash[:error] = I18n.t 'users.update.email_not_changed'
end
end
redirect_to edit_user_path(@user)

View file

@ -61,7 +61,7 @@ class User
person.save if person
end
attr_accessible :getting_started, :password, :password_confirmation, :language, :disable_mail
attr_accessible :getting_started, :password, :password_confirmation, :language, :disable_mail, :email
def strip_and_downcase_username
if username.present?

View file

@ -37,8 +37,12 @@
.span-8.last
%h3
= t('.your_email')
%p
= current_user.email
= form_for @user do |f|
= f.error_messages
%p
= f.label :email, current_user.email
= f.text_field :email
= f.submit t('.change_email')
%br
%br

View file

@ -176,6 +176,7 @@ en:
close_account: "Close Account"
change_language: "Change Language"
change_password: "Change Password"
change_email: "Change Email"
new_password: "New Password"
download_xml: "download my xml"
download_photos: "download my photos"
@ -220,6 +221,8 @@ en:
language_changed: "Language Changed"
language_not_changed: "Language Change Failed"
email_notifications_changed: "Language Change Failed"
email_changed: "Email Changed"
email_not_changed: "Email Change Failed"
public:
does_not_exist: "User %{username} does not exist!"
comments: