From d6606f05bbc0fe3e6e11c95efa5d7c4230f570c6 Mon Sep 17 00:00:00 2001 From: Torsten Date: Wed, 21 Dec 2022 17:30:29 +0200 Subject: [PATCH] scoping devise --- app/controllers/members_controller.rb | 5 ---- app/views/devise/confirmations/new.html.haml | 2 +- app/views/devise/passwords/edit.html.haml | 28 ++++++++----------- app/views/devise/passwords/new.html.haml | 2 +- app/views/devise/registrations/edit.html.haml | 4 +-- app/views/devise/registrations/new.html.haml | 8 +++++- app/views/devise/sessions/new.html.haml | 2 +- app/views/devise/shared/_links.html.haml | 12 ++++---- app/views/devise/unlocks/new.html.haml | 2 +- app/views/layouts/_header.haml | 2 +- app/views/members/new.html.haml | 5 ---- app/views/members/show.html.haml | 4 +++ config/routes.rb | 3 +- 13 files changed, 38 insertions(+), 41 deletions(-) delete mode 100644 app/views/members/new.html.haml diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 56f0bb4..7678e87 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -10,11 +10,6 @@ class MembersController < ApplicationController def show end - # GET /members/new - def new - @member = Member.new - end - # GET /members/1/edit def edit end diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index 63fcfbf..e91cc38 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -3,7 +3,7 @@ %h1.font-hairline.mb-6.text-center Resend Confirmation Instructions = form_for(resource, | as: resource_name, | - url: confirmation_path(resource_name), | + url: main_app.confirmation_path(resource_name), | html: { | method: :post, | class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index c2b1e21..7a3349f 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -1,19 +1,15 @@ .flex.justify-center .w-full.max-w-xs %h2.font-hairline.mb-6.text-center Change Your Password - = form_for(resource, | - as: resource_name, | - url: member_password_path(resource_name), | - html: { | - method: :put, | - class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | - } | - ) do |f| | + = form_for(resource, + as: resource_name, + html: { method: :put, class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" }, + url: member_password_path(resource_name) ) do |f| = render "devise/shared/error_messages", resource: resource = f.hidden_field :reset_password_token .mb-4 - = f.label :password, "New Password", | - class: "block font-bold mb-2 text-gray-700 text-sm" | + = f.label :password, "New Password", + class: "block font-bold mb-2 text-gray-700 text-sm" - if @minimum_password_length %small %em.text-gray-600 @@ -21,16 +17,16 @@ = f.password_field :password, | autofocus: true, | 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" | + 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.label :password_confirmation, | - "Confirm New Password", | - class: "block font-bold mb-2 text-gray-700 text-sm" | + = f.label :password_confirmation, + "Confirm New Password", + class: "block font-bold mb-2 text-gray-700 text-sm" = f.password_field :password_confirmation, | autocomplete: "off", | - 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" | + 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.submit "Change My Password", | - class: "button bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline w-full" | + class: "button bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline w-full" = render "devise/shared/links" = render "devise/shared/form_footer" diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index f97edb4..3758e38 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -3,7 +3,7 @@ %h1.font-hairline.mb-6.text-center Forgot your password? = form_for(resource, | as: resource_name, | - url: password_path(resource_name), | + url: main_app.password_path(resource_name), | html: { | method: :post, | class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index f878093..3f23b2b 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -4,7 +4,7 @@ Edit #{resource_name.to_s.humanize} = form_for(resource, | as: resource_name, | - url: registration_path(resource_name), | + url: main_app.registration_path(resource_name), | html: { | method: :put, | class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | @@ -40,5 +40,5 @@ = f.submit "Update", class: "button bg-blue-500 hover:bg-blue-700 font-bold text-white focus:outline-none py-2 px-4 rounded focus:shadow-outline w-full" %p Unhappy? - %span= button_to "Delete my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete + %span= button_to "Delete my account", main_app.registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete = link_to "Back", :back diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 6654e70..eedef3a 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -3,12 +3,18 @@ %h1.font-hairline.mb-6.text-center Sign Up = form_for(resource, | as: resource_name, | - url: registration_path(resource_name), | + url: main_app.registration_path(resource_name), | html: { | class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | } | ) do |f| | = render "devise/shared/error_messages", resource: resource + .mb-4 + = f.label :name, class: "block font-bold mb-2 text-gray-700 text-sm" + = f.text_field :name, | + autocomplete: "name", | + placeholder: "Pekka Juustonen", | + class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline" | .mb-4 = f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm" = f.email_field :email, | diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index caa6172..24441f3 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -3,7 +3,7 @@ %h1.font-hairline.mb-6.text-center Log In = form_for(resource, | as: resource_name, | - url: session_path(resource_name), | + url: main_app.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/shared/_links.html.haml b/app/views/devise/shared/_links.html.haml index b095c8e..fe7b151 100644 --- a/app/views/devise/shared/_links.html.haml +++ b/app/views/devise/shared/_links.html.haml @@ -1,25 +1,25 @@ - if controller_name != 'sessions' - = link_to "Log in", new_session_path(resource_name), | + = link_to "Log in", main_app.new_member_session_path(resource_name), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' - = link_to "Forgot Password?", new_member_password_path(resource_name), | + = link_to "Forgot Password?", main_app.new_member_password_path(resource_name), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ - if devise_mapping.registerable? && controller_name != 'registrations' - = link_to "Sign up", new_registration_path(resource_name), | + = link_to "Sign up", main_app.new_member_registration_path(resource_name), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ - if devise_mapping.confirmable? && controller_name != 'confirmations' - = link_to "Didn't receive confirmation info?", new_member_confirmation_path(resource_name), | + = link_to "Didn't receive confirmation info?", main_app.new_member_confirmation_path(resource_name), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' - = link_to "Didn't receive unlock info?", new_member_unlock_path(resource_name), | + = link_to "Didn't receive unlock info?", main_app.new_member_unlock_path(resource_name), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ - if devise_mapping.omniauthable? - resource_class.omniauth_providers.each do |provider| - = link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), | + = link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", main_app.omniauth_authorize_path(resource_name, provider), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index 951b17d..d60592c 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -3,7 +3,7 @@ %h1.font-hairline.mb-6.text-center Resend Unlock Info = form_for(resource, | as: resource_name, | - url: unlock_path(resource_name), | + url: main_app.unlock_path(resource_name), | html: { | method: :post, | class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | diff --git a/app/views/layouts/_header.haml b/app/views/layouts/_header.haml index b05baf6..aa3a402 100644 --- a/app/views/layouts/_header.haml +++ b/app/views/layouts/_header.haml @@ -15,7 +15,7 @@ .inline-flex.items-center.justify-center.h-12.px-6.font-medium.tracking-wide.text-white.transition.duration-200.rounded-lg.shadow-md.bg-green-800.hover:bg-blue-800.focus:shadow-outline.focus:outline-none =link_to current_member.email , main_app.member_path(current_member) - else - %a.inline-flex.items-center.justify-center.h-12.px-6.font-medium.tracking-wide.text-white.transition.duration-200.rounded-lg.shadow-md.bg-green-800.hover:bg-blue-800.focus:shadow-outline.focus:outline-none{"aria-label" => "Sign up", :href => member_session_url, :title => "Log in or Sign up"} + %a.inline-flex.items-center.justify-center.h-12.px-6.font-medium.tracking-wide.text-white.transition.duration-200.rounded-lg.shadow-md.bg-green-800.hover:bg-blue-800.focus:shadow-outline.focus:outline-none{"aria-label" => "Sign up", :href => main_app.member_session_path, :title => "Log in or Sign up"} Login .lg:hidden.flex.items-center.justify-between .mr-20 diff --git a/app/views/members/new.html.haml b/app/views/members/new.html.haml deleted file mode 100644 index a71d1ef..0000000 --- a/app/views/members/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -%h1 New member - -= render 'form' - -= link_to 'Back', members_path diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 1f22a3c..dedbd58 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -10,3 +10,7 @@ = link_to 'Edit', edit_member_path(@member) \| = link_to 'Back', members_path +\| += form_tag( destroy_member_session_path , {method: :delete } ) do + %button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400{type: :submit} + Sign out diff --git a/config/routes.rb b/config/routes.rb index afa79cc..f19c51f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,9 @@ Rails.application.routes.draw do + devise_for :members + resources :members - devise_for :members mount Merged::Engine => "/merged"