From: Dessalines Date: Sun, 29 Dec 2019 01:58:01 +0000 (-0500) Subject: Fixing non-existent user profile viewing. X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%24%7B%60data:application/%22https:/hacktivis.me/%7BpictrsAvatarThumbnail%28this.props.site.site.icon%29%7D?a=commitdiff_plain;h=d57b2d486522635485dd3a26df2a6dcfeb0ef634;p=lemmy.git Fixing non-existent user profile viewing. - Fixes #381 --- 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) {