aboutsummaryrefslogtreecommitdiff
path: root/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/db.rs b/src/db.rs
index 85e259b..c655cf7 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -235,10 +235,14 @@ impl DB {
}
}
- pub async fn new_user(&mut self, name: String, password: String, id: UID) -> Result<(), String> {
+ pub async fn new_user(&mut self, name: String, password: String, id: UID) -> Result<User, String> {
let user = User::new(name, password, id);
- self.users.push(user);
- self.save().await
+ self.users.push(user.clone());
+ match self.save().await {
+ Ok(_) => Ok(user),
+ Err(n) => Err(n),
+ }
+
}
pub async fn login(&mut self, id: UID, password: &String, clientid: &String) -> Result<String, String> {