1
0

Remove name field (and remove existing data) (#935)

* Remove name field (and remove existing data)

* run prep, fmt

* fix dummy data
This commit is contained in:
Geometrically
2024-09-06 20:16:28 -07:00
committed by GitHub
parent 637a923e84
commit 2e35f3608b
14 changed files with 67 additions and 133 deletions

View File

@@ -999,7 +999,7 @@ pub async fn stripe_webhook(
let price = match metadata.product_price.prices {
Price::OneTime { price } => Some(price),
Price::Recurring { intervals } => {
if let Some((subscription_id, interval)) =
if let Some((_subscription_id, interval)) =
metadata.user_subscription_data
{
if let Some(mut user_subscription) = metadata.user_subscription {

View File

@@ -65,7 +65,6 @@ pub struct TempUser {
pub avatar_url: Option<String>,
pub bio: Option<String>,
pub name: Option<String>,
pub country: Option<String>,
}
@@ -221,7 +220,6 @@ impl TempUser {
stripe_customer_id: None,
totp_secret: None,
username,
name: self.name,
email: self.email,
email_verified: true,
avatar_url,
@@ -578,7 +576,6 @@ impl AuthProvider {
email: github_user.email,
avatar_url: Some(github_user.avatar_url),
bio: github_user.bio,
name: github_user.name,
country: None,
}
}
@@ -610,7 +607,6 @@ impl AuthProvider {
.avatar
.map(|x| format!("https://cdn.discordapp.com/avatars/{}/{}.webp", id, x)),
bio: None,
name: discord_user.global_name,
country: None,
}
}
@@ -619,7 +615,6 @@ impl AuthProvider {
#[serde(rename_all = "camelCase")]
pub struct MicrosoftUser {
pub id: String,
pub display_name: Option<String>,
pub mail: Option<String>,
pub user_principal_name: String,
}
@@ -642,7 +637,6 @@ impl AuthProvider {
email: microsoft_user.mail,
avatar_url: None,
bio: None,
name: microsoft_user.display_name,
country: None,
}
}
@@ -672,7 +666,6 @@ impl AuthProvider {
email: gitlab_user.email,
avatar_url: gitlab_user.avatar_url,
bio: gitlab_user.bio,
name: gitlab_user.name,
country: None,
}
}
@@ -681,7 +674,6 @@ impl AuthProvider {
pub struct GoogleUser {
pub id: String,
pub email: String,
pub name: Option<String>,
pub picture: Option<String>,
}
@@ -705,7 +697,6 @@ impl AuthProvider {
email: Some(google_user.email),
avatar_url: google_user.picture,
bio: None,
name: google_user.name,
country: None,
}
}
@@ -725,7 +716,6 @@ impl AuthProvider {
#[derive(Deserialize)]
struct Player {
steamid: String,
personaname: String,
profileurl: String,
avatar: Option<String>,
}
@@ -757,7 +747,6 @@ impl AuthProvider {
email: None,
avatar_url: player.avatar,
bio: None,
name: Some(player.personaname),
country: None,
}
} else {
@@ -802,7 +791,6 @@ impl AuthProvider {
email: Some(paypal_user.email),
avatar_url: paypal_user.picture,
bio: None,
name: None,
country: Some(paypal_user.address.country),
}
}
@@ -1527,7 +1515,6 @@ pub async fn create_account_with_password(
stripe_customer_id: None,
totp_secret: None,
username: new_account.username.clone(),
name: Some(new_account.username),
email: Some(new_account.email.clone()),
email_verified: false,
avatar_url: None,
@@ -2068,11 +2055,7 @@ pub async fn change_password(
let update_password = if let Some(new_password) = &change_password.new_password {
let score = zxcvbn::zxcvbn(
new_password,
&[
&user.username,
&user.email.clone().unwrap_or_default(),
&user.name.unwrap_or_default(),
],
&[&user.username, &user.email.clone().unwrap_or_default()],
)?;
if score.score() < 3 {

View File

@@ -163,7 +163,6 @@ pub async fn user_edit(
info,
web::Json(v3::users::EditUser {
username: new_user.username,
name: new_user.name,
bio: new_user.bio,
role: new_user.role,
badges: new_user.badges,

View File

@@ -274,13 +274,6 @@ pub struct EditUser {
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
#[validate(length(min = 1, max = 64), regex = "RE_URL_SAFE")]
pub name: Option<Option<String>>,
#[serde(
default,
skip_serializing_if = "Option::is_none",
with = "::serde_with::rust::double_option"
)]
#[validate(length(max = 160))]
pub bio: Option<Option<String>>,
pub role: Option<Role>,
@@ -345,20 +338,6 @@ pub async fn user_edit(
}
}
if let Some(name) = &new_user.name {
sqlx::query!(
"
UPDATE users
SET name = $1
WHERE (id = $2)
",
name.as_deref(),
id as crate::database::models::ids::UserId,
)
.execute(&mut *transaction)
.await?;
}
if let Some(bio) = &new_user.bio {
sqlx::query!(
"