myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2883] trunk/app: Add recaptcha support for user


From: noreply
Subject: [myexperiment-hackers] [2883] trunk/app: Add recaptcha support for user invitations.
Date: Thu, 15 Dec 2011 06:11:37 -0500 (EST)

Revision
2883
Author
dtm
Date
2011-12-15 06:11:37 -0500 (Thu, 15 Dec 2011)

Log Message

Add recaptcha support for user invitations.

Modified Paths

Diff

Modified: trunk/app/controllers/users_controller.rb (2882 => 2883)


--- trunk/app/controllers/users_controller.rb	2011-12-14 16:08:28 UTC (rev 2882)
+++ trunk/app/controllers/users_controller.rb	2011-12-15 11:11:37 UTC (rev 2883)
@@ -409,7 +409,13 @@
   
   def process_invitations
     # first of all, check that captcha was entered correctly
-    if !captcha_valid?(params[:invitations][:captcha_id], params[:invitations][:captcha_validation])
+    captcha_verified = false
+    if Conf.recaptcha_enable
+      captcha_verified = verify_recaptcha(:private_key => Conf.recaptcha_private)
+    else
+      captcha_verified = captcha_valid?(params[:invitations][:captcha_id], params[:invitations][:captcha_validation])
+    end
+    if !captcha_verified
       respond_to do |format|
         flash.now[:error] = 'Verification text was not entered correctly - your invitations have not been sent.'
         format.html { render :action ="" 'invite' }

Modified: trunk/app/views/users/_invite.rhtml (2882 => 2883)


--- trunk/app/views/users/_invite.rhtml	2011-12-14 16:08:28 UTC (rev 2882)
+++ trunk/app/views/users/_invite.rhtml	2011-12-15 11:11:37 UTC (rev 2883)
@@ -26,6 +26,9 @@
 		<table style="margin-top: 2em;">
 			<tr>
 				<td>
+		<% if Conf.recaptcha_enable -%>
+			<%= recaptcha_tags(:public_key => Conf.recaptcha_public) -%>
+		 <% else -%>
 		      <% c = prepare_captcha :type => :image -%>
 					<%= captcha_image_tag c -%>
 				</td>
@@ -33,6 +36,7 @@
 				  <%= captcha_hidden_field c, 'invitations' -%>
 					<%= captcha_label 'invitations', 'Type in the text from the image on the left:' -%><br/>
 	        <%= captcha_text_field 'invitations', :size => 40 -%>
+		<% end %>
 				</td>
 			</tr>
 		</table>

reply via email to

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