From 3a85515bd5923fde9353290c2f4df5e74b42c27a Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 28 Dec 2019 20:58:01 -0500 Subject: [PATCH] Fixing non-existent user profile viewing. - Fixes #381 --- .travis.yml | 1 - server/src/api/user.rs | 8 +++++--- ui/src/components/user.tsx | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e4d4244..dfdcbf7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,6 @@ before_install: - cd server script: - cargo build - - cargo install diesel_cli --no-default-features --features postgres - diesel migration run - cargo test env: diff --git a/server/src/api/user.rs b/server/src/api/user.rs index 9a343427..a04ba4b2 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -367,11 +367,13 @@ impl Perform for Oper { let user_details_id = match data.user_id { Some(id) => id, None => { - User_::read_from_name( + match User_::read_from_name( &conn, data.username.to_owned().unwrap_or("admin".to_string()), - )? - .id + ) { + Ok(user) => user.id, + Err(_e) => return Err(APIError::err(&self.op, "couldnt_find_that_username_or_email"))? + } } }; diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index 2624a966..6d6a2e0c 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -777,6 +777,9 @@ export class User extends Component { if (msg.error) { alert(i18n.t(msg.error)); this.state.deleteAccountLoading = false; + if (msg.error == 'couldnt_find_that_username_or_email') { + this.context.router.history.push('/'); + } this.setState(this.state); return; } else if (op == UserOperation.GetUserDetails) {