]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_controller.rb
Add functional tests for user blocks
[rails.git] / app / controllers / user_controller.rb
index 1d86c0524de727d0d9a7b27c727a87de78458a88..a086c9f697e86ed10cf5229213bd7150e1b50498 100644 (file)
@@ -38,7 +38,7 @@ class UserController < ApplicationController
       else
         render :action => 'terms'
       end
-    elsif params[:user] and Acl.match(request.remote_ip, params[:user][:email].split("@").last).where(:k => "no_account_creation").exists?
+    elsif params[:user] and Acl.no_account_creation(request.remote_ip, params[:user][:email].split("@").last)
       render :action => 'blocked'
     else
       session[:referer] = params[:referer]
@@ -112,7 +112,7 @@ class UserController < ApplicationController
       else
         redirect_to :action => :account, :display_name => @user.display_name
       end
-    elsif Acl.match(request.remote_ip, params[:user][:email].split("@").last).where(:k => "no_account_creation").exists?
+    elsif Acl.no_account_creation(request.remote_ip, params[:user][:email].split("@").last)
       render :action => 'blocked'
     else
       @user = User.new(params[:user])
@@ -151,7 +151,11 @@ class UserController < ApplicationController
         @user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
       end
 
-      @user.description = params[:user][:description]
+      if params[:user][:description] != @user.description
+        @user.description = params[:user][:description]
+        @user.description_format = "markdown"
+      end
+
       @user.languages = params[:user][:languages].split(",")
 
       case params[:image_action]
@@ -271,7 +275,7 @@ class UserController < ApplicationController
                        :openid_url => params[:openid])
 
       flash.now[:notice] = t 'user.new.openid association'
-    elsif Acl.match(request.remote_ip).where(:k => "no_account_creation").exists?
+    elsif Acl.no_account_creation(request.remote_ip)
       render :action => 'blocked'
     end
   end
@@ -473,7 +477,8 @@ class UserController < ApplicationController
   ##
   # sets a user's status
   def set_status
-    @this_user.update_attributes(:status => params[:status])
+    @this_user.status = params[:status]
+    @this_user.save
     redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name]
   end
 
@@ -624,7 +629,7 @@ private
     cookies.permanent["_osm_username"] = user.display_name
 
     session[:user] = user.id
-    session_expires_after 1.month if session[:remember_me]
+    session_expires_after 28.days if session[:remember_me]
 
     target = session[:referer] || url_for(:controller => :site, :action => :index)
 
@@ -663,6 +668,8 @@ private
     if user.save
       set_locale
 
+      cookies.permanent["_osm_username"] = user.display_name
+
       if user.new_email.blank?
         flash.now[:notice] = t 'user.account.flash update success'
       else
@@ -715,7 +722,7 @@ private
   # Choose the layout to use. See
   # https://rails.lighthouseapp.com/projects/8994/tickets/5371-layout-with-onlyexcept-options-makes-other-actions-render-without-layouts
   def choose_layout
-    oauth_url = url_for(:controller => :oauth, :action => :oauthorize, :only_path => true)
+    oauth_url = url_for(:controller => :oauth, :action => :authorize, :only_path => true)
 
     if [ 'api_details' ].include? action_name
       nil