mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 17:47:22 +00:00
30 lines
543 B
SQL
30 lines
543 B
SQL
CREATE
|
|
OR
|
|
ALTER PROCEDURE dbo.USP_InvalidateUserCredential(
|
|
@UserAccountId_ UNIQUEIDENTIFIER
|
|
)
|
|
AS
|
|
BEGIN
|
|
SET
|
|
NOCOUNT ON;
|
|
SET
|
|
XACT_ABORT ON;
|
|
|
|
BEGIN
|
|
TRANSACTION;
|
|
|
|
EXEC dbo.USP_GetUserAccountByID @UserAccountId = @UserAccountId_;
|
|
IF
|
|
@@ROWCOUNT = 0
|
|
THROW 50001, 'User account not found', 1;
|
|
|
|
-- invalidate all other credentials by setting them to revoked
|
|
UPDATE dbo.UserCredential
|
|
SET IsRevoked = 1,
|
|
RevokedAt = GETDATE()
|
|
WHERE UserAccountId = @UserAccountId_
|
|
AND IsRevoked != 1;
|
|
|
|
|
|
COMMIT TRANSACTION;
|
|
END; |