Skip to content

Commit

Permalink
wip: user messages
Browse files Browse the repository at this point in the history
  • Loading branch information
cilki committed Dec 28, 2024
1 parent 6b777f3 commit 404b431
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 226 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- x86_64-unknown-linux-gnu
# - x86_64-unknown-linux-musl
steps:
- run: sudo apt-get install -y libwayland-dev libasound2-dev libudev-dev
- run: sudo apt-get install -y libwayland-dev libasound2-dev libudev-dev libfuse3-dev

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -72,4 +72,3 @@ jobs:
with:
name: android_artifacts
path: target/x/debug/android/*.apk

34 changes: 0 additions & 34 deletions core/sandpolis-core-instance/src/main/json/User.json

This file was deleted.

160 changes: 0 additions & 160 deletions core/sandpolis-core-instance/src/main/python/connection.py

This file was deleted.

64 changes: 40 additions & 24 deletions sandpolis/src/core/user.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@

// Create a new user account.
message PostUserRequest {
#[derive(Clone, Serialize, Deserialize, Validate)]
pub struct UserData {
/// Unchangable username
#[validate(length(min = 4), length(max = 20))]
pub username: String,

// The user's immutable username
string username = 1;
/// Whether the user is an admin
pub admin: bool,

// The user's password
string password = 2;
/// Email address
#[validate(email)]
pub email: Option<String>,

// The user's token for TOTP verification
string totp_token = 3;
/// Phone number
#[validate(phone)]
pub phone: Option<String>,

// The user's optional email
string email = 4;
pub expiration: Option<i64>,
}

// The user's optional phone number
string phone = 5;
/// Create a new user account.
pub struct CreateUserRequest {

// The user's optional expiration timestamp
int64 expiration = 6;
pub data: UserData,

/// Initial password as unsalted hash
pub password: String,

/// TOTP secret URL
pub totp_secret: Option<URL>,
}

pub enum CreateUserResponse {
Ok,
}

message GetUserResponse {
Expand All @@ -40,18 +54,20 @@ message GetUsersResponse {
repeated GetUserResponse user = 1;
}

// Update an existing user account.
message PutUserRequest {
/// Update an existing user account.
pub struct UpdateUserRequest {

// The user's new password
string password = 1;
pub username: String,

// The user's new email
string email = 2;
/// New password
pub password: Option<String>,

// The user's new phone number
string phone = 3;
/// New email
pub email: Option<String>,

// The user's new expiration timestamp
int64 expiration = 4;
/// New phone number
pub phone: Option<String>,

/// New expiration timestamp
pub expiration: Option<u64>,
}
12 changes: 6 additions & 6 deletions sandpolis/src/server/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ pub struct PasswordHash {
pub hash: String,
}

#[derive(Clone, Serialize, Deserialize, Validate, Default)]
#[derive(Clone, Serialize, Deserialize, Validate)]
pub struct User {
/// The user's unchangable username
/// Unchangable username
#[validate(length(min = 4), length(max = 20))]
pub username: String,

/// Whether the user is an admin
pub admin: bool,

/// The user's password hash
/// Password hash
pub password: PasswordHash,

/// The user's TOTP secret token
/// TOTP secret token
pub totp_secret: Option<String>,

/// The user's optional email address
/// Email address
#[validate(email)]
pub email: Option<String>,

/// The user's optional phone number
/// Phone number
#[validate(phone)]
pub phone: Option<String>,

Expand Down

0 comments on commit 404b431

Please sign in to comment.