Some more tests. Fix invitation link and password reset links. After creating their account and setting a password, the user is logged in
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
Dan Milne
2025-10-26 23:09:38 +11:00
parent 8dd3e60071
commit 431e947a4c
4 changed files with 20 additions and 93 deletions

View File

@@ -1,4 +1,5 @@
class InvitationsController < ApplicationController
include Authentication
allow_unauthenticated_access
before_action :set_user_by_invitation_token, only: %i[ show update ]
@@ -10,7 +11,8 @@ class InvitationsController < ApplicationController
if @user.update(params.permit(:password, :password_confirmation))
@user.update!(status: :active)
@user.sessions.destroy_all
redirect_to new_session_path, notice: "Your account has been set up successfully. Please sign in."
start_new_session_for @user
redirect_to root_path, notice: "Your account has been set up successfully. Welcome!"
else
redirect_to invite_path(params[:token]), alert: "Passwords did not match."
end
@@ -19,7 +21,7 @@ class InvitationsController < ApplicationController
private
def set_user_by_invitation_token
@user = User.find_by_invitation_login_token!(params[:token])
@user = User.find_by_token_for(:invitation_login, params[:token])
# Check if user is still pending invitation
unless @user.pending_invitation?