implements a first version of the forms. Missing: a) tests and b) check db constraints (duplicate email "", etc)

This commit is contained in:
kikito
2015-10-16 20:04:16 +02:00
parent 1511f811fd
commit 9cc158540e
8 changed files with 70 additions and 6 deletions

View File

@@ -10,6 +10,22 @@ class Users::RegistrationsController < Devise::RegistrationsController
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
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)
end
def erase_params
params.require(:user).permit(:erase_reason)
end
def after_inactive_sign_up_path_for(resource_or_scope)
users_sign_up_success_path
end

View File

@@ -1,6 +1,9 @@
<div class="row account">
<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) %>

View File

@@ -0,0 +1,27 @@
<i class="icon-angle-left left"></i>&nbsp;<%= 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 %>