diff --git a/assets/translations.yaml b/assets/translations.yaml index 28b8e5c..bfc66fd 100644 --- a/assets/translations.yaml +++ b/assets/translations.yaml @@ -44,7 +44,7 @@ en: 1. Send a message in this room: `login rocketchatusername mysecret` **Warning**: This will store your password *unecrypted* in the database of your homeserver - 1. Login via curl: `curl ${as_url}/rocketchat/login -d '{"rocketchat_server_url": "${rocketchat_url}", "matrix_user_id": "${matrix_user_id}", "username": "rocketchat_user", "password": "mysecret"}'` + 1. Login via curl: `curl ${as_url}/rocketchat/login -d '{"rocketchat_url": "${rocketchat_url}", "matrix_user_id": "${matrix_user_id}", "rocketchat_username": "ROCKETCHAT_USER", "password": "MYSECRET"}'` no_rocketchat_server_connected: "No Rocket.Chat server is connected yet." usage_instructions: | You are logged in. @@ -69,7 +69,7 @@ en: internal_error: "An internal error occurred" handlers: welcome: "Your Rocket.Chat <-> Matrix application service is running" - rocketchat_login_successful: "You are logged in." + rocketchat_login_successful: "You are logged in. Return to your Matrix client and follow the instructions there." errors: admin_room_for_rocketchat_server_not_found: "No admin room found that is connected to the Rocket.Chat server ${rocketchat_url}" authentication_failed: "Authentication failed!" diff --git a/src/matrix-rocketchat/errors.rs b/src/matrix-rocketchat/errors.rs index a4164f7..94d4e83 100644 --- a/src/matrix-rocketchat/errors.rs +++ b/src/matrix-rocketchat/errors.rs @@ -104,8 +104,8 @@ error_chain!{ } InvalidJSON(msg: String) { - description("The provided JSON is not valid.") - display("Could not process request, the submitted data is not valid JSON: {}", msg) + description("The provided data is not valid.") + display("Could not process request, the submitted data is not valid: {}", msg) } InvalidYAML(msg: String) { diff --git a/src/matrix-rocketchat/handlers/events/command_handler.rs b/src/matrix-rocketchat/handlers/events/command_handler.rs index 9286f4c..bd2afa9 100644 --- a/src/matrix-rocketchat/handlers/events/command_handler.rs +++ b/src/matrix-rocketchat/handlers/events/command_handler.rs @@ -412,7 +412,9 @@ impl<'a> CommandHandler<'a> { } else { t!(["admin_room", "login_instructions"]).with_vars(vec![("rocketchat_url", rocketchat_server.rocketchat_url), - ("as_url", as_url)]) + ("as_url", as_url), + ("matrix_user_id", + user.matrix_user_id.to_string())]) } } None => { diff --git a/tests/admin_commands_login.rs b/tests/admin_commands_login.rs index 074ddfe..e8669f9 100644 --- a/tests/admin_commands_login.rs +++ b/tests/admin_commands_login.rs @@ -169,7 +169,7 @@ fn sucessfully_login_via_rest_api() { &HashMap::new(), None) .unwrap(); - assert!(response.contains("You are logged in.")); + assert!(response.contains("You are logged in. Return to your Matrix client and follow the instructions there.")); assert!(status_code.is_success()); // discard welcome message @@ -274,7 +274,7 @@ fn login_multiple_times_via_rest_message() { &HashMap::new(), None) .unwrap(); - assert!(response.contains("You are logged in.")); + assert!(response.contains("You are logged in. Return to your Matrix client and follow the instructions there.")); assert!(status_code.is_success()); let message_received_by_matrix = receiver.recv_timeout(default_timeout()).unwrap(); assert!(message_received_by_matrix.contains("You are logged in.")); @@ -301,7 +301,8 @@ fn login_via_rest_api_with_invalid_payload() { &HashMap::new(), None) .unwrap(); - assert!(response.contains("Could not process request, the submitted data is not valid JSON")); + println!("MSG: {}", &response); + assert!(response.contains("Could not process request, the submitted data is not valid")); assert_eq!(status_code, status::UnprocessableEntity); }