implements a first version of the forms. Missing: a) tests and b) check db constraints (duplicate email "", etc)
This commit is contained in:
@@ -10,6 +10,22 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_form
|
||||||
|
build_resource({})
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete
|
||||||
|
# The only difference between this version of delete and the original are the following two lines
|
||||||
|
# (we build the resource differently and we also call erase instead of destroy)
|
||||||
|
build_resource(erase_params)
|
||||||
|
resource.erase(params[:erase_reason])
|
||||||
|
|
||||||
|
yield resource if block_given?
|
||||||
|
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
||||||
|
set_flash_message :notice, :destroyed if is_flashing_format?
|
||||||
|
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -32,6 +48,10 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||||||
params.require(:user).permit(:username, :email, :password, :password_confirmation, :captcha, :captcha_key, :terms_of_service)
|
params.require(:user).permit(:username, :email, :password, :password_confirmation, :captcha, :captcha_key, :terms_of_service)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def erase_params
|
||||||
|
params.require(:user).permit(:erase_reason)
|
||||||
|
end
|
||||||
|
|
||||||
def after_inactive_sign_up_path_for(resource_or_scope)
|
def after_inactive_sign_up_path_for(resource_or_scope)
|
||||||
users_sign_up_success_path
|
users_sign_up_success_path
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<div class="row account">
|
<div class="row account">
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= link_to t("account.show.change_credentials_link"), edit_user_registration_path, class: "button radius small secondary right" %>
|
<div class="right">
|
||||||
|
<%= link_to t("account.show.change_credentials_link"), edit_user_registration_path, class: "button radius small secondary" %>
|
||||||
|
<%= link_to t("account.show.erase_account_link"), users_registrations_delete_form_path, class: "button radius small danger" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<%= avatar_image(@account, seed: @account.id, size: 60) %>
|
<%= avatar_image(@account, seed: @account.id, size: 60) %>
|
||||||
|
|
||||||
|
|||||||
27
app/views/users/registrations/delete_form.html.erb
Normal file
27
app/views/users/registrations/delete_form.html.erb
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<i class="icon-angle-left left"></i> <%= link_to t("devise_views.users.registrations.edit.back_link"), :back, class: "left back" %>
|
||||||
|
|
||||||
|
<h1><%= t("devise_views.users.registrations.delete_form.title") %></h1>
|
||||||
|
|
||||||
|
<%= form_for(resource, as: resource_name,
|
||||||
|
url: users_registrations_path,
|
||||||
|
html: { method: :delete }) do |f| %>
|
||||||
|
<%= devise_error_messages! %>
|
||||||
|
<p>
|
||||||
|
<%= t("devise_views.users.registrations.delete_form.info") %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= f.text_field :erase_reason,
|
||||||
|
autofocus: true,
|
||||||
|
placeholder: t("devise_views.users.registrations.delete_form.erase_reason_label"),
|
||||||
|
label: t("devise_views.users.registrations.delete_form.erase_reason_label") %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= f.submit t("devise_views.users.registrations.delete_form.submit"), class: "button radius danger" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
@@ -59,6 +59,11 @@ en:
|
|||||||
need_current: "We need your current password to confirm your changes"
|
need_current: "We need your current password to confirm your changes"
|
||||||
update_submit: "Update"
|
update_submit: "Update"
|
||||||
back_link: "Back"
|
back_link: "Back"
|
||||||
|
delete_form:
|
||||||
|
title: "Erase account"
|
||||||
|
info: "This action can not be undone. Please make sure this is what you want. If you want, you can leave us a reason (this is not mandatory)"
|
||||||
|
erase_reason_label: "Reason"
|
||||||
|
submit: "Erase my account"
|
||||||
new:
|
new:
|
||||||
title: "Sign up"
|
title: "Sign up"
|
||||||
username_label: "Username"
|
username_label: "Username"
|
||||||
|
|||||||
@@ -77,6 +77,11 @@ es:
|
|||||||
instructions_1_html: "Por favor <b>revisa tu correo electrónico</b> - te hemos enviado un <b>enlace para confirmar tu cuenta</b>."
|
instructions_1_html: "Por favor <b>revisa tu correo electrónico</b> - te hemos enviado un <b>enlace para confirmar tu cuenta</b>."
|
||||||
instructions_2_html: "Una vez confirmado, podrás empezar a participar."
|
instructions_2_html: "Una vez confirmado, podrás empezar a participar."
|
||||||
back_to_index: "Entendido, volver a la página principal"
|
back_to_index: "Entendido, volver a la página principal"
|
||||||
|
delete_form:
|
||||||
|
title: "Darme de baja"
|
||||||
|
info: "Esta acción no se puede deshacer. Una vez que des de baja tu cuenta, no podrás volver a hacer login con ella. Si quieres, puedes informarnos de la razón por la que de tas de baja (no es obligatorio)."
|
||||||
|
erase_reason_label: "Razón de la baja"
|
||||||
|
submit: "Borrar mi cuenta"
|
||||||
organizations:
|
organizations:
|
||||||
registrations:
|
registrations:
|
||||||
new:
|
new:
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ en:
|
|||||||
change_credentials_link: "Change my credentials"
|
change_credentials_link: "Change my credentials"
|
||||||
email_on_comment_label: "Receive email when someone comments on my debates or proposals"
|
email_on_comment_label: "Receive email when someone comments on my debates or proposals"
|
||||||
email_on_comment_reply_label: "Receive email when someone replies to my comments"
|
email_on_comment_reply_label: "Receive email when someone replies to my comments"
|
||||||
|
erase_account_link: "Erase my account"
|
||||||
personal: "Personal data"
|
personal: "Personal data"
|
||||||
username_label: "Username"
|
username_label: "Username"
|
||||||
phone_number_label: "Phone number"
|
phone_number_label: "Phone number"
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ es:
|
|||||||
change_credentials_link: "Cambiar mis datos de acceso"
|
change_credentials_link: "Cambiar mis datos de acceso"
|
||||||
email_on_comment_label: "Recibir un email cuando alguien comenta en mis propuestas o debates"
|
email_on_comment_label: "Recibir un email cuando alguien comenta en mis propuestas o debates"
|
||||||
email_on_comment_reply_label: "Recibir un email cuando alguien contesta a mis comentarios"
|
email_on_comment_reply_label: "Recibir un email cuando alguien contesta a mis comentarios"
|
||||||
|
erase_account_link: "Darme de baja"
|
||||||
personal: "Datos personales"
|
personal: "Datos personales"
|
||||||
username_label: "Nombre de usuario"
|
username_label: "Nombre de usuario"
|
||||||
phone_number_label: "Teléfono"
|
phone_number_label: "Teléfono"
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
as :user do
|
|
||||||
match '/user/confirmation' => 'users/confirmations#update', :via => :patch, :as => :update_user_confirmation
|
|
||||||
end
|
|
||||||
|
|
||||||
devise_for :users, controllers: {
|
devise_for :users, controllers: {
|
||||||
registrations: 'users/registrations',
|
registrations: 'users/registrations',
|
||||||
sessions: 'users/sessions',
|
sessions: 'users/sessions',
|
||||||
@@ -22,7 +18,11 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
|
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
|
patch '/user/confirmation', to: 'users/confirmations#update', as: :update_user_confirmation
|
||||||
|
|
||||||
get 'users/sign_up/success', to: 'users/registrations#success'
|
get 'users/sign_up/success', to: 'users/registrations#success'
|
||||||
|
get 'users/registrations/delete_form', to: 'users/registrations#delete_form'
|
||||||
|
delete 'users/registrations', to: 'users/registrations#delete'
|
||||||
get :finish_signup, to: 'users/registrations#finish_signup'
|
get :finish_signup, to: 'users/registrations#finish_signup'
|
||||||
patch :do_finish_signup, to: 'users/registrations#do_finish_signup'
|
patch :do_finish_signup, to: 'users/registrations#do_finish_signup'
|
||||||
end
|
end
|
||||||
@@ -60,7 +60,9 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :account, controller: "account", only: [:show, :update]
|
resource :account, controller: "account", only: [:show, :update, :delete] do
|
||||||
|
collection { get :erase }
|
||||||
|
end
|
||||||
resource :verification, controller: "verification", only: [:show]
|
resource :verification, controller: "verification", only: [:show]
|
||||||
|
|
||||||
scope module: :verification do
|
scope module: :verification do
|
||||||
|
|||||||
Reference in New Issue
Block a user