fix: upsert OPEN_LEARNER seed password by email
Use email-based ON CONFLICT to refresh bcrypt hash when the account pre-exists, and repair null or invalid passwords for the Reach for Change seed user. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
d546ae4df0
commit
cbbde85e65
|
|
@ -205,7 +205,29 @@ VALUES
|
||||||
CURRENT_TIMESTAMP,
|
CURRENT_TIMESTAMP,
|
||||||
NULL
|
NULL
|
||||||
)
|
)
|
||||||
ON CONFLICT (id) DO NOTHING;
|
ON CONFLICT ((LOWER(email))) WHERE email IS NOT NULL DO UPDATE SET
|
||||||
|
password = EXCLUDED.password,
|
||||||
|
role = EXCLUDED.role,
|
||||||
|
email_verified = EXCLUDED.email_verified,
|
||||||
|
phone_verified = EXCLUDED.phone_verified,
|
||||||
|
status = EXCLUDED.status,
|
||||||
|
first_name = EXCLUDED.first_name,
|
||||||
|
last_name = EXCLUDED.last_name,
|
||||||
|
updated_at = CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- Ensure bcrypt password if the account pre-existed (OAuth / OTP signup without password).
|
||||||
|
UPDATE users
|
||||||
|
SET
|
||||||
|
password = crypt('password@123', gen_salt('bf'))::bytea,
|
||||||
|
role = 'OPEN_LEARNER',
|
||||||
|
email_verified = TRUE,
|
||||||
|
status = 'ACTIVE',
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
WHERE LOWER(TRIM(email)) = 'tsegaye.negera@reachforchange.org'
|
||||||
|
AND (
|
||||||
|
password IS NULL
|
||||||
|
OR length(password) < 60
|
||||||
|
);
|
||||||
|
|
||||||
-- ======================================================
|
-- ======================================================
|
||||||
-- Team Members / Admin Panel Users (login via /api/v1/team/login)
|
-- Team Members / Admin Panel Users (login via /api/v1/team/login)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user