myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3030] trunk/app/controllers/users_controller.rb:


From: noreply
Subject: [myexperiment-hackers] [3030] trunk/app/controllers/users_controller.rb: improved performance of confirm_email
Date: Wed, 13 Jun 2012 15:11:26 +0000 (UTC)

Revision
3030
Author
dgc
Date
2012-06-13 15:11:26 +0000 (Wed, 13 Jun 2012)

Log Message

improved performance of confirm_email

Modified Paths

Diff

Modified: trunk/app/controllers/users_controller.rb (3029 => 3030)


--- trunk/app/controllers/users_controller.rb	2012-06-13 13:57:45 UTC (rev 3029)
+++ trunk/app/controllers/users_controller.rb	2012-06-13 15:11:26 UTC (rev 3030)
@@ -276,26 +276,24 @@
 
     confirmed = false
     
-    for user in @users
-      unless user.unconfirmed_email.blank?
-        # Check if hash matches user, in which case confirm the user's email
-        if user.email_confirmation_hash == params[:hash]
-          confirmed = user.confirm_email!
-          # BEGIN DEBUG
-          logger.error("ERRORS!") unless user.errors.empty?
-          user.errors.full_messages.each { |e| logger.error(e) } 
-          #END DEBUG
-          if confirmed
-            self.current_user = user
-            self.current_user.process_pending_invitations! # look up any pending invites for this user + transfer them to relevant tables from 'pending_invitations' table
-            confirmed = false if !logged_in?
-          end
-          @user = user
-          break
-        end
+    user = User.find(:first,
+        :conditions => ['SHA1(CONCAT(users.unconfirmed_email, ?)) = ?', Conf.secret_word,
+        params[:hash]])
+
+    if user
+      confirmed = user.confirm_email!
+      # BEGIN DEBUG
+      logger.error("ERRORS!") unless user.errors.empty?
+      user.errors.full_messages.each { |e| logger.error(e) } 
+      #END DEBUG
+      if confirmed
+        self.current_user = user
+        self.current_user.process_pending_invitations! # look up any pending invites for this user + transfer them to relevant tables from 'pending_invitations' table
+        confirmed = false if !logged_in?
       end
+      @user = user
     end
-    
+
     respond_to do |format|
       if confirmed
         flash[:notice] = "Thank you for confirming your email address.  Welcome to #{Conf.sitename}!"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]