Translation (WIP)
This commit is contained in:
parent
9b0fcec5e2
commit
e9873c1943
29 changed files with 586 additions and 285 deletions
|
|
@ -76,7 +76,7 @@ FROM [UserLoginToken] WHERE [token] = $1
|
|||
}
|
||||
|
||||
pub async fn load_user(&self, user_id: i64) -> Result<Option<model::User>> {
|
||||
sqlx::query_as("SELECT [id], [email], [name] FROM [User] WHERE [id] = $1")
|
||||
sqlx::query_as("SELECT [id], [email], [name], [lang] FROM [User] WHERE [id] = $1")
|
||||
.bind(user_id)
|
||||
.fetch_optional(&self.pool)
|
||||
.await
|
||||
|
|
@ -102,13 +102,14 @@ FROM [UserLoginToken] WHERE [token] = $1
|
|||
.fetch_one(&mut *tx)
|
||||
.await?;
|
||||
|
||||
let new_email = new_email.map(str::trim);
|
||||
let email_changed = new_email.is_some_and(|new_email| new_email != email);
|
||||
|
||||
// Check if email not already taken.
|
||||
let validation_token = if email_changed {
|
||||
if sqlx::query_scalar::<_, i64>(
|
||||
if sqlx::query_scalar(
|
||||
r#"
|
||||
SELECT COUNT(*)
|
||||
SELECT COUNT(*) > 0
|
||||
FROM [User]
|
||||
WHERE [email] = $1
|
||||
"#,
|
||||
|
|
@ -116,7 +117,6 @@ WHERE [email] = $1
|
|||
.bind(new_email.unwrap())
|
||||
.fetch_one(&mut *tx)
|
||||
.await?
|
||||
> 0
|
||||
{
|
||||
return Ok(UpdateUserResult::EmailAlreadyTaken);
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ WHERE [id] = $1
|
|||
)
|
||||
.bind(user_id)
|
||||
.bind(new_email.unwrap_or(&email))
|
||||
.bind(new_name.unwrap_or(&name))
|
||||
.bind(new_name.map(str::trim).unwrap_or(&name))
|
||||
.bind(hashed_new_password.unwrap_or(hashed_password))
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue