]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_controller.rb
Use "confirm_email" instead "confirm email" in resource names so it
[rails.git] / app / controllers / user_controller.rb
index d83cac0da8790343dcaa11d8718f84da8739746c..1dbc9368dc440b387e1966cec3670f65dfd1e9ec 100644 (file)
@@ -2,8 +2,8 @@ class UserController < ApplicationController
   layout 'site'
 
   before_filter :authorize, :only => [:api_details, :api_gpx_files]
-  before_filter :set_locale, :except => [:api_details, :api_gpx_files]
   before_filter :authorize_web, :except => [:api_details, :api_gpx_files]
+  before_filter :set_locale, :except => [:api_details, :api_gpx_files]
   before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image, :delete_image]
   before_filter :check_database_readable, :except => [:api_details, :api_gpx_files]
   before_filter :check_database_writable, :only => [:login, :new, :set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image, :delete_image]
@@ -23,8 +23,7 @@ class UserController < ApplicationController
       @user.data_public = true
       @user.description = "" if @user.description.nil?
       @user.creation_ip = request.remote_ip
-      @user.locale = Language.find_by_code(I18n.locale.to_s)
-      @user.locale = Language.find_by_code("en") if @user.locale.nil?
+      @user.languages = request.user_preferred_languages
 
       if @user.save
         flash[:notice] = I18n.t('user.new.flash create success message')
@@ -51,10 +50,13 @@ class UserController < ApplicationController
       end
 
       @user.description = params[:user][:description]
+      @user.languages = params[:user][:languages].split(",")
       @user.home_lat = params[:user][:home_lat]
       @user.home_lon = params[:user][:home_lon]
 
       if @user.save
+        set_locale
+
         if params[:user][:email] == @user.new_email
           flash[:notice] = I18n.t('user.account.flash update success confirm needed')
           Notifier.deliver_email_confirm(@user, @user.tokens.create)
@@ -91,7 +93,7 @@ class UserController < ApplicationController
       if user
         token = user.tokens.create
         Notifier.deliver_lost_password(user, token)
-        flash[:notice] = I18n.t('user.lost_password.notice.email on way')
+        flash[:notice] = I18n.t('user.lost_password.notice email on way')
       else
         flash[:notice] = I18n.t('user.lost_password.notice email cannot find')
       end
@@ -152,9 +154,9 @@ class UserController < ApplicationController
         end
         return
       elsif User.authenticate(:username => email_or_display_name, :password => pass, :inactive => true)
-        @notice = "Sorry, your account is not active yet.<br>Please click on the link in the account confirmation email to activate your account."
+        @notice = I18n.t('user.login.account not active')
       else
-        @notice = "Sorry, couldn't log in with those details."
+        @notice = I18n.t('user.login.auth failure')
       end
     end
   end
@@ -184,11 +186,11 @@ class UserController < ApplicationController
         @user.email_valid = true
         @user.save!
         token.destroy
-        flash[:notice] = 'Confirmed your account, thanks for signing up!'
+        flash[:notice] = I18n.t('user.confirm.success')
         session[:user] = @user.id
         redirect_to :action => 'account', :display_name => @user.display_name
       else
-        @notice = 'Something went wrong confirming that user.'
+        @notice = I18n.t('user.confirm.failure')
       end
     end
   end
@@ -204,11 +206,11 @@ class UserController < ApplicationController
         @user.email_valid = true
         @user.save!
         token.destroy
-        flash[:notice] = 'Confirmed your email address, thanks for signing up!'
+        flash[:notice] = I18n.t('user.confirm_email.success')
         session[:user] = @user.id
         redirect_to :action => 'account', :display_name => @user.display_name
       else
-        @notice = 'Something went wrong confirming that email address.'
+        @notice = I18n.t('user.confirm_email.failure')
       end
     end
   end