fix logout
This commit is contained in:
@@ -14,7 +14,7 @@ class PasswordResetsController < ApplicationController
|
|||||||
reset_password_sent_at: Time.current
|
reset_password_sent_at: Time.current
|
||||||
)
|
)
|
||||||
PasswordResetMailer.reset(@user).deliver_later
|
PasswordResetMailer.reset(@user).deliver_later
|
||||||
else
|
elsif @user.present?
|
||||||
@user.invite_by!
|
@user.invite_by!
|
||||||
InvitationMailer.invite(@user).deliver_later
|
InvitationMailer.invite(@user).deliver_later
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ class SessionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
# Skip authentication if rate limited
|
|
||||||
return if @rate_limited
|
|
||||||
|
|
||||||
user = User.find_by(email: params[:email]&.downcase&.strip)
|
user = User.find_by(email: params[:email]&.downcase&.strip)
|
||||||
|
|
||||||
if user&.authenticate(params[:password])
|
if user&.authenticate(params[:password])
|
||||||
@@ -50,6 +47,6 @@ class SessionsController < ApplicationController
|
|||||||
current_user&.forget_me if cookies.signed[:remember_token]
|
current_user&.forget_me if cookies.signed[:remember_token]
|
||||||
reset_session
|
reset_session
|
||||||
cookies.delete(:remember_token)
|
cookies.delete(:remember_token)
|
||||||
redirect_to root_path, notice: "You have been logged out."
|
redirect_to root_path, notice: "You have been logged out.", status: :see_other
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<% if admin? %>
|
<% if admin? %>
|
||||||
<%= link_to "Admin", admin_root_path, class: "bg-indigo-600 text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-indigo-700 transition" %>
|
<%= link_to "Admin", admin_root_path, class: "bg-indigo-600 text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-indigo-700 transition" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to "Sign Out", logout_path, data: { turbo_method: :delete, turbo: false },
|
<%= link_to "Sign Out", logout_path, data: { turbo_method: :delete },
|
||||||
class: "text-sm font-medium text-slate-600 hover:text-red-600 transition" %>
|
class: "text-sm font-medium text-slate-600 hover:text-red-600 transition" %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
@@ -74,8 +74,8 @@
|
|||||||
<% if admin? %>
|
<% if admin? %>
|
||||||
<%= link_to "Admin", admin_root_path, class: "px-2 py-2 text-sm font-medium text-indigo-700 hover:bg-indigo-50 rounded transition" %>
|
<%= link_to "Admin", admin_root_path, class: "px-2 py-2 text-sm font-medium text-indigo-700 hover:bg-indigo-50 rounded transition" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to "Sign Out", logout_path, data: { turbo_method: :delete, turbo: false },
|
<%= link_to "Sign Out", logout_path, data: { turbo_method: :delete },
|
||||||
class: "px-2 py-2 text-sm font-medium text-red-600 hover:bg-red-50 rounded transition" %>
|
class: "block px-2 py-2 text-sm font-medium text-red-600 hover:bg-red-50 rounded transition" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to "Sign In", login_path, class: "px-2 py-2 text-sm font-medium text-indigo-700 hover:bg-indigo-50 rounded transition" %>
|
<%= link_to "Sign In", login_path, class: "px-2 py-2 text-sm font-medium text-indigo-700 hover:bg-indigo-50 rounded transition" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ Rails.application.routes.draw do
|
|||||||
# Authentication routes
|
# Authentication routes
|
||||||
get "login", to: "sessions#new", as: :login
|
get "login", to: "sessions#new", as: :login
|
||||||
post "login", to: "sessions#create"
|
post "login", to: "sessions#create"
|
||||||
get "logout", to: "sessions#destroy", as: :logout
|
delete "logout", to: "sessions#destroy", as: :logout
|
||||||
|
|
||||||
# Password reset routes
|
# Password reset routes
|
||||||
resources :password_resets, only: [ :new, :create ]
|
resources :password_resets, only: [ :new, :create ]
|
||||||
|
|||||||
Reference in New Issue
Block a user