-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix External ID not set during DC Sync
While working on the fix I realised the location where the `external_id` is stored was wrong. It was stored in the `users` table, but it actually should have been stored in the `users_organizations` table. This will move the column to the right table. It will not move the values of the `external_id` column, because if there are more organizations, there is no way to really know which organization it is linked to. Setups using the Directory Connector can clear the sync cache, and sync again, that will store all the `external_id` values at the right location. Also changed the function to revoke,restore an org-user and set_external_id to return a boolean. It will state if the value has been changed or not, and if not, we can prevent a `save` call to the database.
- Loading branch information
Showing
12 changed files
with
125 additions
and
45 deletions.
There are no files selected for viewing
Empty file.
5 changes: 5 additions & 0 deletions
5
migrations/mysql/2023-09-02-212336_move_user_external_id/up.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,5 @@ | ||
ALTER TABLE users | ||
DROP COLUMN external_id; | ||
|
||
ALTER TABLE users_organizations | ||
ADD COLUMN external_id TEXT; |
Empty file.
5 changes: 5 additions & 0 deletions
5
migrations/postgresql/2023-09-02-212336_move_user_external_id/up.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,5 @@ | ||
ALTER TABLE users | ||
DROP COLUMN external_id; | ||
|
||
ALTER TABLE users_organizations | ||
ADD COLUMN external_id TEXT; |
Empty file.
48 changes: 48 additions & 0 deletions
48
migrations/sqlite/2023-09-02-212336_move_user_external_id/up.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,48 @@ | ||
-- Create new users table without the external_id column | ||
CREATE TABLE users_new ( | ||
"uuid" TEXT NOT NULL, | ||
"created_at" DATETIME NOT NULL, | ||
"updated_at" DATETIME NOT NULL, | ||
"email" TEXT NOT NULL UNIQUE, | ||
"name" TEXT NOT NULL, | ||
"password_hash" BLOB NOT NULL, | ||
"salt" BLOB NOT NULL, | ||
"password_iterations" INTEGER NOT NULL, | ||
"password_hint" TEXT, | ||
"akey" TEXT NOT NULL, | ||
"private_key" TEXT, | ||
"public_key" TEXT, | ||
"totp_secret" TEXT, | ||
"totp_recover" TEXT, | ||
"security_stamp" TEXT NOT NULL, | ||
"equivalent_domains" TEXT NOT NULL, | ||
"excluded_globals" TEXT NOT NULL, | ||
"client_kdf_type" INTEGER NOT NULL DEFAULT 0, | ||
"client_kdf_iter" INTEGER NOT NULL DEFAULT 600000, | ||
"verified_at" DATETIME DEFAULT NULL, | ||
"last_verifying_at" DATETIME DEFAULT NULL, | ||
"login_verify_count" INTEGER NOT NULL DEFAULT 0, | ||
"email_new" TEXT DEFAULT NULL, | ||
"email_new_token" TEXT DEFAULT NULL, | ||
"enabled" BOOLEAN NOT NULL DEFAULT 1, | ||
"stamp_exception" TEXT DEFAULT NULL, | ||
"api_key" TEXT, | ||
"avatar_color" TEXT, | ||
"client_kdf_memory" INTEGER DEFAULT NULL, | ||
"client_kdf_parallelism" INTEGER DEFAULT NULL, | ||
PRIMARY KEY ("uuid") | ||
); | ||
|
||
-- Transfer current data to new table | ||
INSERT INTO "users_new" ("akey","api_key","avatar_color","client_kdf_iter","client_kdf_memory","client_kdf_parallelism","client_kdf_type","created_at","email","email_new","email_new_token","enabled","equivalent_domains","excluded_globals","last_verifying_at","login_verify_count","name","password_hash","password_hint","password_iterations","private_key","public_key","salt","security_stamp","stamp_exception","totp_recover","totp_secret","updated_at","uuid","verified_at") | ||
SELECT "akey","api_key","avatar_color","client_kdf_iter","client_kdf_memory","client_kdf_parallelism","client_kdf_type","created_at","email","email_new","email_new_token","enabled","equivalent_domains","excluded_globals","last_verifying_at","login_verify_count","name","password_hash","password_hint","password_iterations","private_key","public_key","salt","security_stamp","stamp_exception","totp_recover","totp_secret","updated_at","uuid","verified_at" | ||
FROM "users"; | ||
|
||
-- Drop the old table | ||
DROP TABLE "users"; | ||
|
||
-- Rename the new table to the original name | ||
ALTER TABLE "users_new" RENAME TO "users"; | ||
|
||
-- Add the external_id to the users_organizations table | ||
ALTER TABLE "users_organizations" ADD COLUMN "external_id" TEXT; |
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
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
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