From 48e0569832c7a72df98152c882fa3f7db9c73f90 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 14 Dec 2019 15:20:11 -0600 Subject: [PATCH] login: add /login & /logout routes, rename 'sign in' to 'login'. * Replace /session/new with /login and /session/sign_out with /logout. * Rename 'sign in' to 'login'. This changes are to make urls cleaner and terminology more consistent. --- app/controllers/users_controller.rb | 4 ++-- app/javascript/src/styles/base/040_colors.css | 4 ++-- app/javascript/src/styles/common/page_header.scss | 4 ++-- app/views/layouts/_main_links.html.erb | 2 +- app/views/sessions/new.html.erb | 4 ++-- app/views/static/access_denied.html.erb | 2 +- app/views/static/site_map.html.erb | 2 +- app/views/user_upgrades/new.html.erb | 2 +- app/views/users/_secondary_links.html.erb | 2 +- config/routes.rb | 2 ++ 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3dd6432c4..696b26ae0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -17,7 +17,7 @@ class UsersController < ApplicationController @user = CurrentUser.user if @user.is_anonymous? - redirect_to new_session_path + redirect_to login_path(url: settings_path) else params[:action] = "edit" respond_with(@user, template: "users/edit") @@ -54,7 +54,7 @@ class UsersController < ApplicationController params[:action] = "show" respond_with(@user, methods: @user.full_attributes, template: "users/show") elsif request.format.html? - redirect_to new_session_path + redirect_to login_path(url: profile_path) else raise ActiveRecord::RecordNotFound end diff --git a/app/javascript/src/styles/base/040_colors.css b/app/javascript/src/styles/base/040_colors.css index e2c5ad565..7cbbdb8a8 100644 --- a/app/javascript/src/styles/base/040_colors.css +++ b/app/javascript/src/styles/base/040_colors.css @@ -161,7 +161,7 @@ --bulk-update-request-approved-color: green; --bulk-update-request-failed-color: red; - --sign-in-link-color: #E00; + --login-link-color: #E00; --footer-border: 1px solid #EEE; --jquery-ui-widget-content-background: var(--body-background-color); @@ -434,7 +434,7 @@ body[data-user-theme="dark"] { --wiki-page-versions-diff-ins-background: var(--green-0); --low-post-count-color: var(--red-1); - --sign-in-link-color: var(--red-1); + --login-link-color: var(--red-1); --new-artist-color: var(--red-1); --remove-favorite-button: var(--red-1); --fetch-source-data-border: 1px solid var(--grey-4); diff --git a/app/javascript/src/styles/common/page_header.scss b/app/javascript/src/styles/common/page_header.scss index 77b9de8fa..a9a65f8fc 100644 --- a/app/javascript/src/styles/common/page_header.scss +++ b/app/javascript/src/styles/common/page_header.scss @@ -41,9 +41,9 @@ header#top { font-weight: bold; } - li#nav-sign-in a { + li#nav-login a { font-weight: bold; - color: var(--sign-in-link-color); + color: var(--login-link-color); } li.forum-updated a { diff --git a/app/views/layouts/_main_links.html.erb b/app/views/layouts/_main_links.html.erb index 09de054ed..a16ed243c 100644 --- a/app/views/layouts/_main_links.html.erb +++ b/app/views/layouts/_main_links.html.erb @@ -1,6 +1,6 @@ <% if CurrentUser.is_anonymous? %> - <%= nav_link_to("Sign in", new_session_path) %> + <%= nav_link_to("Login", login_path) %> <% else %> <%= nav_link_to("My Account #{CurrentUser.dmail_count}", profile_path) %> <% end %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index f328220cd..e35bb95c7 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,7 +1,7 @@
-

Sign in

+

Login

<%= simple_form_for(:session, url: session_path) do |f| %> <%= f.input :url, as: :hidden, input_html: { value: params[:url] } %> @@ -17,7 +17,7 @@
<% content_for(:page_title) do %> - Sign in - <%= Danbooru.config.app_name %> + Login - <%= Danbooru.config.app_name %> <% end %> <%= render "secondary_links" %> diff --git a/app/views/static/access_denied.html.erb b/app/views/static/access_denied.html.erb index f5dd3db64..721fac640 100644 --- a/app/views/static/access_denied.html.erb +++ b/app/views/static/access_denied.html.erb @@ -4,7 +4,7 @@ You do not have permission to visit this page. <% if CurrentUser.is_anonymous? %> - Try <%= link_to "logging in", new_session_path(url: request.fullpath) %> or + Try <%= link_to "logging in", login_path(url: request.fullpath) %> or <%= link_to "signing up", new_user_path %>. <% end %>

diff --git a/app/views/static/site_map.html.erb b/app/views/static/site_map.html.erb index 65accf367..06f6d618e 100644 --- a/app/views/static/site_map.html.erb +++ b/app/views/static/site_map.html.erb @@ -118,7 +118,7 @@
  • Profile

  • <% if CurrentUser.is_anonymous? %> -
  • <%= link_to "Sign in", new_session_path %>
  • +
  • <%= link_to "Login", login_path %>
  • <%= link_to "Sign up", new_user_path %>
  • <% else %>
  • <%= link_to "Profile", profile_path %>
  • diff --git a/app/views/user_upgrades/new.html.erb b/app/views/user_upgrades/new.html.erb index efcc9d25d..436249e08 100644 --- a/app/views/user_upgrades/new.html.erb +++ b/app/views/user_upgrades/new.html.erb @@ -101,7 +101,7 @@ <% if Danbooru.config.stripe_publishable_key %> <% if CurrentUser.is_anonymous? %> -

    <%= link_to "Sign up", new_user_path %> or <%= link_to "login", new_session_path(url: new_user_upgrade_path) %> first to upgrade your account.

    +

    <%= link_to "Sign up", new_user_path %> or <%= link_to "login", login_path(url: new_user_upgrade_path) %> first to upgrade your account.

    <% elsif CurrentUser.safe_mode? %> <%= render "stripe_payment" %> <% else %> diff --git a/app/views/users/_secondary_links.html.erb b/app/views/users/_secondary_links.html.erb index 6257c83b8..ab204888f 100644 --- a/app/views/users/_secondary_links.html.erb +++ b/app/views/users/_secondary_links.html.erb @@ -34,6 +34,6 @@ <% end %>
  • |
  • - <%= subnav_link_to "Sign out", sign_out_session_path %> + <%= subnav_link_to "Log out", logout_path %> <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 275bc18a8..e79834876 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -385,6 +385,8 @@ Rails.application.routes.draw do get "/user/show/:id" => redirect("/users/%{id}") get "/user/login" => redirect("/sessions/new") get "/user_record" => redirect {|params, req| "/user_feedbacks?search[user_id]=#{req.params[:user_id]}"} + get "/login", to: "sessions#new", as: :login + get "/logout", to: "sessions#sign_out", as: :logout get "/profile", to: "users#profile", as: :profile get "/settings", to: "users#settings", as: :settings