You've already forked AstralRinth
forked from didirus/AstralRinth
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:
@@ -51,7 +51,6 @@ where
|
||||
let user = User {
|
||||
id: UserId::from(db_user.id),
|
||||
username: db_user.username,
|
||||
name: db_user.name,
|
||||
email: db_user.email,
|
||||
email_verified: Some(db_user.email_verified),
|
||||
avatar_url: db_user.avatar_url,
|
||||
|
||||
@@ -37,7 +37,6 @@ pub struct User {
|
||||
pub totp_secret: Option<String>,
|
||||
|
||||
pub username: String,
|
||||
pub name: Option<String>,
|
||||
pub email: Option<String>,
|
||||
pub email_verified: bool,
|
||||
pub avatar_url: Option<String>,
|
||||
@@ -57,7 +56,7 @@ impl User {
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO users (
|
||||
id, username, name, email,
|
||||
id, username, email,
|
||||
avatar_url, bio, created,
|
||||
github_id, discord_id, gitlab_id, google_id, steam_id, microsoft_id,
|
||||
email_verified, password, paypal_id, paypal_country, paypal_email,
|
||||
@@ -67,12 +66,11 @@ impl User {
|
||||
$1, $2, $3, $4, $5,
|
||||
$6, $7,
|
||||
$8, $9, $10, $11, $12, $13,
|
||||
$14, $15, $16, $17, $18, $19, $20
|
||||
$14, $15, $16, $17, $18, $19
|
||||
)
|
||||
",
|
||||
self.id as UserId,
|
||||
&self.username,
|
||||
self.name.as_ref(),
|
||||
self.email.as_ref(),
|
||||
self.avatar_url.as_ref(),
|
||||
self.bio.as_ref(),
|
||||
@@ -166,7 +164,7 @@ impl User {
|
||||
|
||||
let users = sqlx::query!(
|
||||
"
|
||||
SELECT id, name, email,
|
||||
SELECT id, email,
|
||||
avatar_url, username, bio,
|
||||
created, role, badges,
|
||||
balance,
|
||||
@@ -189,7 +187,6 @@ impl User {
|
||||
google_id: u.google_id,
|
||||
steam_id: u.steam_id,
|
||||
microsoft_id: u.microsoft_id,
|
||||
name: u.name,
|
||||
email: u.email,
|
||||
email_verified: u.email_verified,
|
||||
avatar_url: u.avatar_url,
|
||||
|
||||
@@ -35,7 +35,7 @@ impl From<crate::models::v3::users::User> for LegacyUser {
|
||||
Self {
|
||||
id: data.id,
|
||||
username: data.username,
|
||||
name: data.name,
|
||||
name: None,
|
||||
email: data.email,
|
||||
email_verified: data.email_verified,
|
||||
avatar_url: data.avatar_url,
|
||||
|
||||
@@ -39,7 +39,6 @@ impl Default for Badges {
|
||||
pub struct User {
|
||||
pub id: UserId,
|
||||
pub username: String,
|
||||
pub name: Option<String>,
|
||||
pub avatar_url: Option<String>,
|
||||
pub bio: Option<String>,
|
||||
pub created: DateTime<Utc>,
|
||||
@@ -73,7 +72,6 @@ impl From<DBUser> for User {
|
||||
Self {
|
||||
id: data.id.into(),
|
||||
username: data.username,
|
||||
name: data.name,
|
||||
email: None,
|
||||
email_verified: None,
|
||||
avatar_url: data.avatar_url,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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!(
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user