From a975f5a0cd1f3849554d52930f06e2d5e42d4a6c Mon Sep 17 00:00:00 2001 From: Curly Bryce Date: Wed, 3 Jul 2024 20:06:02 -0600 Subject: register now returns name and id --- src/db.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/db.rs') 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 { 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 { -- cgit v1.2.3