diff --git a/auth/migrations/0005_add_beta_access.sql b/auth/migrations/0005_add_beta_access.sql new file mode 100644 index 000000000..3d17c9b11 --- /dev/null +++ b/auth/migrations/0005_add_beta_access.sql @@ -0,0 +1,2 @@ +ALTER TABLE users +ADD COLUMN has_access_to_beta BOOL DEFAULT false; diff --git a/auth/src/user.rs b/auth/src/user.rs index d08814a52..f3d0eae7d 100644 --- a/auth/src/user.rs +++ b/auth/src/user.rs @@ -86,15 +86,16 @@ where P: PermissionsDal + Send + Sync, { async fn create_user(&self, account_name: String, tier: AccountTier) -> Result { - let user = User::new(account_name, ApiKey::generate(), tier, vec![]); + let user = User::new(account_name, ApiKey::generate(), tier, vec![], false); query( - "INSERT INTO users (account_name, key, account_tier, user_id) VALUES ($1, $2, $3, $4)", + "INSERT INTO users (account_name, key, account_tier, user_id, has_access_to_beta) VALUES ($1, $2, $3, $4, $5)", ) .bind(&user.name) .bind(user.key.expose()) .bind(user.account_tier.to_string()) .bind(&user.id) + .bind(false) .execute(&self.pool) .await?; @@ -278,6 +279,7 @@ pub struct User { pub key: Secret, pub account_tier: AccountTier, pub subscriptions: Vec, + pub has_access_to_beta: bool, } #[derive(Clone, Debug)] @@ -310,6 +312,7 @@ impl User { key: ApiKey, account_tier: AccountTier, subscriptions: Vec, + has_access_to_beta: bool, ) -> Self { Self { name, @@ -317,6 +320,7 @@ impl User { key: Secret::new(key), account_tier, subscriptions, + has_access_to_beta, } } @@ -390,6 +394,7 @@ impl FromRow<'_, PgRow> for User { }, )?, subscriptions: vec![], + has_access_to_beta: row.try_get("has_access_to_beta").unwrap(), }) } } @@ -465,6 +470,7 @@ impl From for models::user::Response { key: user.key.expose().as_ref().to_owned(), account_tier: user.account_tier.to_string(), subscriptions: user.subscriptions.into_iter().map(Into::into).collect(), + has_access_to_beta: user.has_access_to_beta, } } } diff --git a/common/src/models/user.rs b/common/src/models/user.rs index 7f866e89f..2a3b5a1b5 100644 --- a/common/src/models/user.rs +++ b/common/src/models/user.rs @@ -13,6 +13,7 @@ pub struct Response { pub key: String, pub account_tier: String, pub subscriptions: Vec, + pub has_access_to_beta: bool, } #[derive(Deserialize, Serialize, Debug)]