change email and password pages

This commit is contained in:
Torsten 2023-01-20 08:15:33 +02:00
parent b296941ca4
commit 58696d2168
5 changed files with 118 additions and 20 deletions

View File

@ -0,0 +1,62 @@
# frozen_string_literal: true
class RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
prepend_before_action :authenticate_scope!, only: [:edit_email]
# POST /resource
def create
puts "CREATE"
super
end
# GET /resource/edit
def edit_email
build_resource
puts "EDIT"
end
def edit
build_resource
super
end
# PUT /resource
def update
puts "UPDATE"
super
end
def resource_name
"member"
end
# DELETE /resource
# def destroy
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_up_params
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
# end
# If you have extra params to permit, append them to the sanitizer.
# def configure_account_update_params
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
# end
# The path used after sign up.
def after_sign_up_path_for(resource)
puts "after sign up"
super(resource)
end
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end

View File

@ -1,26 +1,17 @@
.flex.justify-center
.w-full.max-w-xs
%h1.font-hairline.mb-6.text-center
Edit #{resource_name.to_s.humanize}
%h1.font-hairline.mb-6.text-center.text-2xl
Change password
= form_for(resource, as: resource_name,
html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md",
method: :put } ,
url: registration_path(resource_name) ) do |f|
= render "devise/shared/error_messages", resource: resource
.mb-4
= f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm"
%br/
= f.email_field :email, |
autofocus: true, |
autocomplete: "email", |
class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline" |
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
%div
Currently waiting confirmation for: #{resource.unconfirmed_email}
.mb-4
= f.label :password, class: "block font-bold mb-2 text-gray-700 text-sm"
%i (leave blank if you don't want to change it)
%br/
= f.label :new_password, class: "block font-bold mb-2 text-gray-700 text-sm"
= 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"
@ -34,7 +25,8 @@
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" |
.actions
= f.submit "Update", class: "button bg-cyan-700 hover:bg-cyan-500 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
= link_to "Back", :back
.flex.justify-between
%p
%span= button_to "Delete my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete , class: button_classes
%button{class: button_classes}
= link_to "Back", :back

View File

@ -0,0 +1,32 @@
.flex.justify-center
.w-full.max-w-xs
%h1.font-hairline.mb-6.text-center.text-2xl
Change your email
.text-center.text-lg
(requires confirmation)
= form_for(resource, as: resource_name,
html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md",
method: :put } ,
url: registration_path(resource_name) ) do |f|
= render "devise/shared/error_messages", resource: resource
.mb-4
= f.label :new_email, class: "block font-bold mb-2 text-gray-700 text-sm"
%br/
= f.email_field :email, |
autofocus: true, |
autocomplete: "email", |
class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline" |
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
%div
Currently waiting confirmation for: #{resource.unconfirmed_email}
.mb-4
= f.label :current_password, class: "block font-bold mb-2 text-gray-700 text-sm"
= f.password_field :current_password, |
autocomplete: "current-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" |
.actions
= f.submit "Update", class: "button bg-cyan-700 hover:bg-cyan-500 font-bold text-white focus:outline-none py-2 px-4 rounded focus:shadow-outline w-full"
= link_to :back do
%button{class: button_classes}
Back

View File

@ -46,6 +46,15 @@
%div= entity.type
%div= entity.name
%div= entity.value
= form_tag( destroy_member_session_path , {method: :delete } ) do
%button.mt-10.ml-10.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
.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-3
.flex.justify-beteen
= form_tag( destroy_member_session_path , {method: :delete } ) do
%button.mt-10.ml-10.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
= link_to edit_member_registration_path do
%button.mt-10.ml-10.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400{type: :submit}
Change Password
= link_to members_edit_email_path do
%button.mt-10.ml-10.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400{type: :submit}
Change Email

View File

@ -3,7 +3,10 @@ Rails.application.routes.draw do
resources :profiles
resources :entities
devise_for :members
devise_for :members ,controllers: { registrations: 'registrations' }
devise_scope :member do
get "/members/edit_email" , to: "registrations#edit_email"
end
resources :members