Last active
October 10, 2018 02:34
-
-
Save heavypackets/7307b7a2c52cca7aa53d00cd7d18112e to your computer and use it in GitHub Desktop.
simple-secretes_audit_examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check password | |
if !verify_password(&user_info) { | |
audit_event( | |
ServerEvents::LoginFailureInvalidPassword, | |
&format!( | |
"Login failure for user {} due to invalid password", | |
user_info.username | |
), | |
); | |
unsuccessful_login_counter.inc(); | |
return Ok(Response::with(iron::status::Unauthorized)); | |
} | |
// Generate and set new token | |
user_info.token = generate_authorization_token(); | |
if update_user_token(&user_info).is_ok() { | |
audit_event( | |
ServerEvents::TokenCreated, | |
&format!( | |
"Session token {} for user {} created", | |
user_info.token, user_info.username | |
), | |
); | |
audit_event( | |
ServerEvents::LoginSuccess, | |
&format!("Login success for user {}", user_info.username), | |
); | |
successful_login_counter.inc(); | |
Ok(Response::with((iron::status::Ok, user_info.token))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment