-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove user sessions when password is updated (#4043)
Signed-off-by: Sergio Castaño Arteaga <[email protected]> Signed-off-by: Cintia Sanchez Garcia <[email protected]> Co-authored-by: Sergio Castaño Arteaga <[email protected]> Co-authored-by: Cintia Sanchez Garcia <[email protected]>
- Loading branch information
1 parent
78e386e
commit 219e8b4
Showing
4 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
-- Start transaction and plan tests | ||
begin; | ||
select plan(2); | ||
select plan(4); | ||
|
||
-- Declare some variables | ||
\set user1ID '00000000-0000-0000-0000-000000000001' | ||
|
||
-- Seed user | ||
-- Seed some data | ||
insert into "user" (user_id, alias, email, password) values (:'user1ID', 'user1', '[email protected]', 'old'); | ||
insert into session (session_id, user_id) values (gen_random_bytes(32), :'user1ID'); | ||
|
||
-- Update user password providing correct old password | ||
select update_user_password(:'user1ID', 'old', 'new'); | ||
|
@@ -17,6 +18,16 @@ select results_eq( | |
$$ values ('new') $$, | ||
'User password should have been updated' | ||
); | ||
select is_empty( | ||
$$ | ||
select * from session | ||
where user_id = '00000000-0000-0000-0000-000000000001' | ||
$$, | ||
'User1 sessions should have been deleted after updating the password successfully' | ||
); | ||
|
||
-- Seed some data | ||
insert into session (session_id, user_id) values (gen_random_bytes(32), :'user1ID'); | ||
|
||
-- Try updating user password providing incorrect old password | ||
select update_user_password(:'user1ID', 'incorrect', 'new2'); | ||
|
@@ -27,6 +38,13 @@ select results_eq( | |
$$ values ('new') $$, | ||
'User password should not have been updated' | ||
); | ||
select isnt_empty( | ||
$$ | ||
select * from session | ||
where user_id = '00000000-0000-0000-0000-000000000001' | ||
$$, | ||
'User1 sessions should not have been deleted as the password was not updated' | ||
); | ||
|
||
-- Finish tests and rollback transaction | ||
select * from finish(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters