-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #542 from openziti/password-reset-fix
Fix for multiple password reset requests per account (#452)
- Loading branch information
Showing
4 changed files
with
44 additions
and
1 deletion.
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
7 changes: 7 additions & 0 deletions
7
controller/store/sql/postgresql/018_v0_4_23_password_reset_request_unique.sql
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- +migrate Up | ||
|
||
-- remove the old unique index (users might need multiple password resets) | ||
ALTER TABLE password_reset_requests DROP CONSTRAINT password_reset_requests_account_id_key; | ||
|
||
-- add new constraint which doesnt mind having multiple resets for account ids | ||
ALTER TABLE password_reset_requests ADD CONSTRAINT password_reset_requests_account_id_key FOREIGN KEY (account_id) REFERENCES accounts (id); |
17 changes: 17 additions & 0 deletions
17
controller/store/sql/sqlite3/018_v0_4_23_password_reset_request_unique.sql
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- +migrate Up | ||
|
||
alter table password_reset_requests rename to password_reset_requests_old; | ||
|
||
CREATE TABLE password_reset_requests ( | ||
id integer primary key, | ||
token string not null unique, | ||
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), | ||
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), | ||
account_id integer not null constraint fk_accounts_password_reset_requests references accounts, | ||
deleted boolean not null default(false), | ||
|
||
constraint chk_token check(token <> '') | ||
); | ||
|
||
insert into password_reset_requests select * from password_reset_requests_old; | ||
drop table password_reset_requests_old; |