From: Tom Hughes Date: Tue, 9 Feb 2010 11:54:40 +0000 (+0000) Subject: Display the current email address and any pending new email address X-Git-Tag: live~6949^2~40 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/846699104d2783d2d9d1162196bd428f0af6334e Display the current email address and any pending new email address separately on the user settings page. --- diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 2f22ad940..3a2bc7f0d 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -47,11 +47,8 @@ class UserController < ApplicationController @tokens = @user.oauth_tokens.find :all, :conditions => 'oauth_tokens.invalidated_at is null and oauth_tokens.authorized_at is not null' if params[:user] and params[:user][:display_name] and params[:user][:description] - if params[:user][:email] != @user.email - @user.new_email = params[:user][:email] - end - @user.display_name = params[:user][:display_name] + @user.new_email = params[:user][:new_email] if params[:user][:pass_crypt].length > 0 or params[:user][:pass_crypt_confirmation].length > 0 @user.pass_crypt = params[:user][:pass_crypt] @@ -66,21 +63,20 @@ class UserController < ApplicationController if @user.save set_locale - if params[:user][:email] == @user.new_email + if @user.new_email.nil? or @user.new_email.empty? + flash.now[:notice] = t 'user.account.flash update success' + else flash.now[:notice] = t 'user.account.flash update success confirm needed' Notifier.deliver_email_confirm(@user, @user.tokens.create) - else - flash.now[:notice] = t 'user.account.flash update success' end end else if flash[:errors] flash[:errors].each do |attr,msg| + attr = "new_email" if attr == "email" @user.errors.add(attr,msg) end end - - @user.email = @user.new_email if @user.new_email end end diff --git a/app/views/user/account.html.erb b/app/views/user/account.html.erb index ae00f7b34..e4fa87cc1 100644 --- a/app/views/user/account.html.erb +++ b/app/views/user/account.html.erb @@ -3,7 +3,8 @@ <% form_for :user, @user do |f| %> - + + diff --git a/config/locales/en.yml b/config/locales/en.yml index 7c8a159ee..baff12f9e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1449,6 +1449,8 @@ en: account: title: "Edit account" my settings: My settings + current email address: "Current Email Address:" + new email address: "New Email Address:" email never displayed publicly: "(never displayed publicly)" public editing: heading: "Public editing:"
<%= t 'user.new.display name' %><%= f.text_field :display_name %>
<%= t 'user.new.email address' %><%= f.text_field :email, {:size => 50, :maxlength => 255} %> <%= t 'user.account.email never displayed publicly' %>
<%= t 'user.account.current email address' %><%= @user.email %> <%= t 'user.account.email never displayed publicly' %>
<%= t 'user.account.new email address' %><%= f.text_field :new_email, {:size => 50, :maxlength => 255} %> <%= t 'user.account.email never displayed publicly' %>
<%= t 'user.new.password' %><%= f.password_field :pass_crypt, {:value => '', :size => 30, :maxlength => 255} %>
<%= t 'user.new.confirm password' %><%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255} %>