From 825b85a72e5352603ad5626d9a3dd8df30c4876f Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 1 Dec 2021 14:49:49 +0000 Subject: [PATCH] Clean up user routes --- app/controllers/users/account_controller.rb | 16 +++++++++------- app/views/organisations/users.html.erb | 2 +- ...personal_details.html.erb => edit.html.erb} | 0 config/routes.rb | 18 ++++++++---------- 4 files changed, 18 insertions(+), 18 deletions(-) rename app/views/users/account/{personal_details.html.erb => edit.html.erb} (100%) diff --git a/app/controllers/users/account_controller.rb b/app/controllers/users/account_controller.rb index ccbc9cc31..f696d3ae7 100644 --- a/app/controllers/users/account_controller.rb +++ b/app/controllers/users/account_controller.rb @@ -1,15 +1,9 @@ class Users::AccountController < ApplicationController - def check_logged_in - if current_user.nil? - redirect_to(new_user_session_path) - end - end - def index check_logged_in end - def personal_details + def edit check_logged_in end @@ -19,6 +13,14 @@ class Users::AccountController < ApplicationController 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 diff --git a/app/views/organisations/users.html.erb b/app/views/organisations/users.html.erb index 390d9c0ff..7dce3177e 100644 --- a/app/views/organisations/users.html.erb +++ b/app/views/organisations/users.html.erb @@ -3,7 +3,7 @@ <%= "Users" %> <% end %> -<%= govuk_button_link_to "Invite user", new_user_path, method: :post %> +<%= govuk_button_link_to "Invite user", new_user_registration_path, method: :post %> <%= govuk_table do |table| %> <%= table.head do |head| %> <%= head.row do |row| diff --git a/app/views/users/account/personal_details.html.erb b/app/views/users/account/edit.html.erb similarity index 100% rename from app/views/users/account/personal_details.html.erb rename to app/views/users/account/edit.html.erb diff --git a/config/routes.rb b/config/routes.rb index 3327f8917..bf7e4f384 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,27 +2,25 @@ Rails.application.routes.draw do devise_for :admin_users, ActiveAdmin::Devise.config devise_for :users, controllers: { passwords: "users/passwords", sessions: "users/sessions" }, path_names: { sign_in: "sign-in", sign_out: "sign-out" }, skip: [:registrations] devise_scope :user do + get "user", to: "users/account#index" + get "users", to: "users/account#index" + get "users/new", to: "devise/registrations#new", as: "new_user_registration" + get "users/edit", to: "devise/registrations#edit", as: "edit_user_registration" + get "users/account", to: "users/account#index" get "confirmations/reset", to: "users/passwords#reset_confirmation" - get "users/edit" => "devise/registrations#edit", :as => "edit_user_registration" - patch "users" => "users/registrations#update", :as => "user_registration" - patch "details" => "users/account#update", :as => "account_update" + get "users/account/personal_details", to: "users/account#edit" + patch "users", to: "users/registrations#update", as: "user_registration" + patch "details", to: "users/account#update", as: "account_update" end # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html ActiveAdmin.routes(self) root to: "test#index" get "about", to: "about#index" - get "/users/account", to: "users/account#index" form_handler = FormHandler.instance form = form_handler.get_form("2021_2022") - resources :users do - collection do - get "account/personal-details", to: "users/account#personal_details" - end - end - resources :organisations do member do get "details", to: "organisations#show"