Skip to content

Commit

Permalink
Improve login instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
exul committed Apr 21, 2017
1 parent 5ee11fc commit 92b5055
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions assets/translations.yaml
Expand Up @@ -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.
Expand All @@ -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!"
Expand Down
4 changes: 2 additions & 2 deletions src/matrix-rocketchat/errors.rs
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/matrix-rocketchat/handlers/events/command_handler.rs
Expand Up @@ -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 => {
Expand Down
7 changes: 4 additions & 3 deletions tests/admin_commands_login.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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."));
Expand All @@ -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);
}

Expand Down

0 comments on commit 92b5055

Please sign in to comment.