]> Untitled Git - lemmy.git/commitdiff
Fixing non-existent user profile viewing.
authorDessalines <tyhou13@gmx.com>
Sun, 29 Dec 2019 01:58:01 +0000 (20:58 -0500)
committerDessalines <tyhou13@gmx.com>
Sun, 29 Dec 2019 01:58:01 +0000 (20:58 -0500)
- Fixes #381

.travis.yml
server/src/api/user.rs
ui/src/components/user.tsx

index 1e4d4244ffefccd669b0e262de41be61c93b7d09..dfdcbf7e3884befe4334c97bb002e711f4b5892e 100644 (file)
@@ -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:
index 9a343427439c24d871669bc09a83661ba30dd203..a04ba4b239168b7c7a3c6cf54e2ab3fd5630f6ab 100644 (file)
@@ -367,11 +367,13 @@ impl Perform<GetUserDetailsResponse> for Oper<GetUserDetails> {
     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"))?
+        }
       }
     };
 
index 2624a9662049fecaf9d16fe1103f88b9ef47061e..6d6a2e0cc571ee29d43c181288301f15bf3581a0 100644 (file)
@@ -777,6 +777,9 @@ export class User extends Component<any, UserState> {
     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) {