Bulk User Import Custom Password Hash Issue

Thanks @sidharth.chaudhary,

This Discourse user import flow is now working with this updated query in Step 1

SELECT
    user_emails.email,
    users.active as email_verified,
    concat(
        '$pbkdf2-sha256$i=64000,l=32$',
        replace(encode(users.salt::bytea, 'base64'), '=', ''),
        '$',
        replace(encode(decode(users.password_hash, 'hex'), 'base64'), '=', '')
    ) as password_hash
FROM users
INNER JOIN user_emails 
ON users.id = user_emails.user_id 
AND user_emails.primary IS TRUE
AND users.id > 0

Note that the difference was this line

replace(encode(users.salt::bytea, 'base64'), '=', '')

Cheers :slight_smile:

2 Likes