diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index a28c39e..08429f1 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -6,9 +6,15 @@ class RegistrationsController < Devise::RegistrationsController prepend_before_action :authenticate_scope!, only: [:edit_email] + def new + build_resource + super + end # POST /resource def create - puts "CREATE" + if message = math_check + flash.now.alert = message + end super end @@ -28,16 +34,24 @@ class RegistrationsController < Devise::RegistrationsController super end - def resource_name - "member" - end - # DELETE /resource # def destroy # super # end - # protected + protected + + def math_check + return "no cheatin" unless bot = params[:bot] + return "No food" unless fudder = bot[:fudder] + key = fudder.to_i / 2 + answer = bot[:challenge] + return "Plase enter the bot challenge" if answer.blank? + if( (2*key + 1).to_s != answer ) + return "Check the maths, tip, it wasn't #{answer}" + end + nil + end # If you have extra params to permit, append them to the sanitizer. # def configure_sign_up_params diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index 8ead264..0faa3ed 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -1,5 +1,5 @@ .flex.justify-center - .w-full.max-w-xs + .w-full.max-w-xs.md:max-w-md %h1.font-hairline.mb-6.text-center Resend Confirmation Instructions = form_for(resource, as: resource_name, url: confirmation_path(resource_name), diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index 75056ee..dc9f69a 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -1,5 +1,5 @@ .flex.justify-center - .w-full.max-w-xs + .w-full.max-w-xs.md:max-w-md %h2.font-hairline.mb-6.text-center Change Your Password = form_for(resource, as: resource_name, diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index cbfe3dd..9fa2492 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -1,5 +1,5 @@ .flex.justify-center - .w-full.max-w-xs + .w-full.max-w-xs.md:max-w-md %h1.font-hairline.mb-6.text-center Forgot your password? = form_for(resource, as: resource_name, html: { method: :post, diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index be8c36d..7363603 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -1,5 +1,5 @@ .flex.justify-center - .w-full.max-w-xs + .w-full.max-w-xs.md:max-w-md %h1.font-hairline.mb-6.text-center.text-2xl Change password = form_for(resource, as: resource_name, diff --git a/app/views/devise/registrations/edit_email.html.haml b/app/views/devise/registrations/edit_email.html.haml index 92adee5..bdfd67b 100644 --- a/app/views/devise/registrations/edit_email.html.haml +++ b/app/views/devise/registrations/edit_email.html.haml @@ -1,5 +1,5 @@ .flex.justify-center - .w-full.max-w-xs + .w-full.max-w-xs.md:max-w-md %h1.font-hairline.mb-6.text-center.text-2xl Change your email .text-center.text-lg diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 46a394c..1204781 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,6 +1,6 @@ .flex.justify-center - .w-full.max-w-xs - %h1.font-hairline.mb-6.text-center Sign Up + .w-full.max-w-xs.md:max-w-md + %h1.font-hairline.mb-6.text-center.text-2xl Sign Up = form_for(resource, as: resource_name, html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" } , url: registration_path(resource_name) ) do |f| @@ -17,16 +17,22 @@ %small %em.text-gray-600 (#{@minimum_password_length} characters minimum) - = f.password_field :password, | - autocomplete: "new-password", | - class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline" | + = f.password_field :password, + autocomplete: "new-password", + class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline" .mb-4 = f.label :password_confirmation, class: "block font-bold mb-2 text-gray-700 text-sm" - = f.password_field :password_confirmation, | - autocomplete: "new-password", | - class: "appearance-none border leading-tight focus:outline-none px-3 py-2 rounded shadow focus:shadow-outline text-gray-700 w-full" | - .mb-4 - = f.submit "Sign Up", | - class: "button bg-cyan-700 hover:bg-cyan-700 font-bold text-white focus:outline-none py-2 px-4 rounded focus:shadow-outline w-full" | + = f.password_field :password_confirmation, + autocomplete: "new-password", + class: "appearance-none border leading-tight focus:outline-none px-3 py-2 rounded shadow focus:shadow-outline text-gray-700 w-full" + .mt-4 + - challenge = rand(8) + = simple_fields_for :bot do |n| + = n.input :fudder , as: :hidden , input_html: { value: "#{challenge*2}" } + = n.input :challenge, placeholder: "Anti bot question: #{challenge} + #{challenge + 1} == " , + class: " border leading-tight focus:outline-none px-3 py-2 rounded shadow focus:shadow-outline text-gray-700 w-full" + .my-4 + = f.submit "Sign Up", + class: "button bg-cyan-700 hover:bg-cyan-700 font-bold text-white focus:outline-none py-2 px-4 rounded focus:shadow-outline w-full" = render "devise/shared/links" = render "devise/shared/form_footer" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 722060e..7d19af5 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,5 +1,5 @@ .flex.justify-center - .w-full.max-w-xs + .w-full.max-w-xs.md:max-w-md %h1.font-hairline.mb-6.text-center Log In = form_for(resource, url: session_path(resource_name), html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" }, diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index 1f05ad9..be898f1 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -1,5 +1,5 @@ .flex.justify-center - .w-full.max-w-xs + .w-full.max-w-xs.md:max-w-md %h1.font-hairline.mb-6.text-center Resend Unlock Info = form_for(resource, as: resource_name, html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" ,