18 changed files with 69 additions and 123 deletions
@ -1,4 +1,4 @@
|
||||
class Users::PasswordsController < Devise::PasswordsController |
||||
class Auth::PasswordsController < Devise::PasswordsController |
||||
include Helpers::Email |
||||
|
||||
def reset_confirmation |
@ -1,4 +1,4 @@
|
||||
class Users::SessionsController < Devise::SessionsController |
||||
class Auth::SessionsController < Devise::SessionsController |
||||
include Helpers::Email |
||||
|
||||
def create |
@ -1,27 +0,0 @@
|
||||
class Users::AccountController < ApplicationController |
||||
def index |
||||
check_logged_in |
||||
end |
||||
|
||||
def edit |
||||
check_logged_in |
||||
end |
||||
|
||||
def update |
||||
if current_user.update(user_params) |
||||
redirect_to(users_account_path) |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def check_logged_in |
||||
if current_user.nil? |
||||
redirect_to(new_user_session_path) |
||||
end |
||||
end |
||||
|
||||
def user_params |
||||
params.require(:user).permit(:email, :name, :password) |
||||
end |
||||
end |
@ -1,14 +0,0 @@
|
||||
class Users::RegistrationsController < Devise::RegistrationsController |
||||
skip_before_action :require_no_authentication |
||||
|
||||
def new |
||||
self.resource = resource_class.new |
||||
respond_with resource |
||||
end |
||||
|
||||
protected |
||||
|
||||
def after_update_path_for(_resource) |
||||
users_account_path |
||||
end |
||||
end |
@ -0,0 +1,23 @@
|
||||
class UsersController < ApplicationController |
||||
before_action :authenticate_user! |
||||
|
||||
def update |
||||
if current_user.update(user_params) |
||||
redirect_to(user_path) |
||||
end |
||||
end |
||||
|
||||
def new |
||||
@resource = User.new |
||||
end |
||||
|
||||
def create |
||||
User.create!(user_params) |
||||
end |
||||
|
||||
private |
||||
|
||||
def user_params |
||||
params.require(:user).permit(:email, :name, :password) |
||||
end |
||||
end |
@ -1,18 +1,26 @@
|
||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> |
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: 'Back', |
||||
href: :back, |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(current_user, as: :user, url: account_update_path(), html: { method: :patch }) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<h1 class="govuk-heading-l">Reset your password</h1> |
||||
<%= render "devise/shared/error_messages", resource: resource %> |
||||
<h1 class="govuk-heading-l">Change your password</h1> |
||||
|
||||
<%= f.hidden_field :reset_password_token %> |
||||
<%= f.govuk_password_field :current_password, |
||||
label: { text: "Current password" }, |
||||
autocomplete: "current-password" |
||||
%> |
||||
|
||||
<%= f.govuk_password_field :password, |
||||
label: { text: "New password" }, |
||||
hint: @minimum_password_length ? { text: "Your password must be at least #{@minimum_password_length} characters and hard to guess." } : nil, |
||||
autocomplete: "new-password" |
||||
%> |
||||
|
||||
<%= f.govuk_submit "Reset password" %> |
||||
<%= f.govuk_submit "Update" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
|
@ -1,26 +0,0 @@
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: 'Back', |
||||
href: :back, |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(resource, as: resource_name, url: user_registration_path(), html: { method: :patch }) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<h1 class="govuk-heading-l">Change your password</h1> |
||||
|
||||
<%= f.govuk_password_field :current_password, |
||||
label: { text: "Current password" }, |
||||
autocomplete: "current-password" |
||||
%> |
||||
|
||||
<%= f.govuk_password_field :password, |
||||
hint: @minimum_password_length ? { text: "Your password must be at least #{@minimum_password_length} characters and hard to guess." } : nil, |
||||
autocomplete: "new-password" |
||||
%> |
||||
|
||||
<%= f.govuk_submit "Update" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -1,15 +0,0 @@
|
||||
<% if resource.errors.any? %> |
||||
<div id="error_explanation"> |
||||
<h2> |
||||
<%= I18n.t("errors.messages.not_saved", |
||||
count: resource.errors.count, |
||||
resource: resource.class.model_name.human.downcase) |
||||
%> |
||||
</h2> |
||||
<ul> |
||||
<% resource.errors.full_messages.each do |message| %> |
||||
<li><%= message %></li> |
||||
<% end %> |
||||
</ul> |
||||
</div> |
||||
<% end %> |
Loading…
Reference in new issue