chore(database): generate user UUID based on `{username}${sha512_pass}`
This commit is contained in:
parent
fe7e4ff03f
commit
7300bda67c
|
@ -26,10 +26,6 @@ impl User {
|
||||||
// change username to lowercase
|
// change username to lowercase
|
||||||
let username = 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
|
// salting the password
|
||||||
let password = format!("{username}${password}");
|
let password = format!("{username}${password}");
|
||||||
|
|
||||||
|
@ -39,6 +35,13 @@ impl User {
|
||||||
password.as_bytes(),
|
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`
|
// return `User`
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
|
|
Loading…
Reference in New Issue