]> git.openstreetmap.org Git - rails.git/commitdiff
Require a form post to finally confirm an account to stop
authorTom Hughes <tom@compton.nu>
Thu, 29 May 2008 20:43:58 +0000 (20:43 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 29 May 2008 20:43:58 +0000 (20:43 +0000)
accidental confirmations.

app/controllers/user_controller.rb
app/views/user/confirm.rhtml

index e998e83c69d86e843f4763f2e42e41bfd295034c..31955d019dd13417f98421898733575c40b441bd 100644 (file)
@@ -143,17 +143,19 @@ class UserController < ApplicationController
   end
 
   def confirm
-    token = UserToken.find_by_token(params[:confirm_string])
-    if token and !token.user.active?
-      @user = token.user
-      @user.active = true
-      @user.save!
-      token.destroy
-      flash[:notice] = 'Confirmed your account, thanks for signing up!'
-      session[:user] = @user.id
-      redirect_to :action => 'account', :display_name => @user.display_name
-    else
-      flash[:notice] = 'Something went wrong confirming that user.'
+    if params[:confirm_action]
+      token = UserToken.find_by_token(params[:confirm_string])
+      if token and !token.user.active?
+        @user = token.user
+        @user.active = true
+        @user.save!
+        token.destroy
+        flash[:notice] = 'Confirmed your account, thanks for signing up!'
+        session[:user] = @user.id
+        redirect_to :action => 'account', :display_name => @user.display_name
+      else
+        flash[:notice] = 'Something went wrong confirming that user.'
+      end
     end
   end
 
index 8b137891791fe96927ad78e64b0aad7bded08bdc..5577b7068889c6c2694644ed477bbea77cf21fd7 100644 (file)
@@ -1 +1,10 @@
+<h1>Confirm a user account</h1>
+
+<p>Press the confirm button below to activate your account.</p>
+
+<form method="post">
+<input type="hidden" name="confirm_string" value="<%= params[:confirm_string] %>">
+<input type="submit" name="confirm_action" value="Confrm">
+</form>
+