chore(database): generate user UUID based on `{username}${sha512_pass}`

This commit is contained in:
MedzikUser 2022-06-18 13:44:18 +02:00
parent fe7e4ff03f
commit 7300bda67c
No known key found for this signature in database
GPG Key ID: A5FAC1E185C112DB
1 changed files with 7 additions and 4 deletions

View File

@ -26,10 +26,6 @@ impl User {
// change username to lowercase
let username = username.to_lowercase();
// generate a user UUID
let sha1_name = CryptographicHash::hash(Algorithm::SHA1, username.as_bytes());
let id = Uuid::new_v5(&Uuid::NAMESPACE_X500, &sha1_name).to_string();
// salting the password
let password = format!("{username}${password}");
@ -39,6 +35,13 @@ impl User {
password.as_bytes(),
));
// generate a user UUID
let id_sha1 = CryptographicHash::hash(
Algorithm::SHA1,
(format!("{username}${password}")).as_bytes(),
);
let id = Uuid::new_v5(&Uuid::NAMESPACE_X500, &id_sha1).to_string();
// return `User`
Self {
id,