]> git.openstreetmap.org Git - rails.git/commitdiff
Display the current email address and any pending new email address
authorTom Hughes <tom@compton.nu>
Tue, 9 Feb 2010 11:54:40 +0000 (11:54 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 9 Feb 2010 11:54:40 +0000 (11:54 +0000)
separately on the user settings page.

app/controllers/user_controller.rb
app/views/user/account.html.erb
config/locales/en.yml

index 2f22ad940448e8e7f74c6e875b185db7b68626c8..3a2bc7f0d333afc45626413517575cae7b4cc5dd 100644 (file)
@@ -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
 
index ae00f7b34c8cb2a61d002b5255a8be89536fef9a..e4fa87cc1109ea390bc78b344f3e3096253acbd1 100644 (file)
@@ -3,7 +3,8 @@
 <% form_for :user, @user do |f| %>
 <table id="accountForm">
   <tr><td class="fieldName"><%= t 'user.new.display name' %></td><td><%= f.text_field :display_name %></td></tr>
-  <tr><td class="fieldName"><%= t 'user.new.email address' %></td><td><%= f.text_field :email, {:size => 50, :maxlength => 255} %> <span class="minorNote"><%= t 'user.account.email never displayed publicly' %></span></td></tr>
+  <tr><td class="fieldName" style="padding-bottom:0px;"><%= t 'user.account.current email address' %></td><td style="padding-bottom:0px;"><%= @user.email %> <span class="minorNote"><%= t 'user.account.email never displayed publicly' %></span></td></tr>
+  <tr><td class="fieldName"><%= t 'user.account.new email address' %></td><td><%= f.text_field :new_email, {:size => 50, :maxlength => 255} %> <span class="minorNote"><%= t 'user.account.email never displayed publicly' %></span></td></tr>
   <tr><td class="fieldName" style="padding-bottom:0px;"><%= t 'user.new.password' %></td><td style="padding-bottom:0px;"><%= f.password_field :pass_crypt, {:value => '', :size => 30, :maxlength => 255} %></td></tr>
   <tr><td class="fieldName"><%= t 'user.new.confirm password' %></td><td><%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255} %></td></tr>
 
index 7c8a159ee1915d3a8ec7f6bae454fefdc4b44b9a..baff12f9ec79b53e743c120a543eb39d65a92167 100644 (file)
@@ -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:"