Create authentication request guard #17
|
@ -34,7 +34,7 @@ pub fn validate_new_passwords(new_password1: &str, new_password2: &str) -> Resul
|
|||
}
|
||||
}
|
||||
|
||||
/// Uses htpasswd to set a new password for the admin user
|
||||
/// Sets a new password for the admin user
|
||||
notplants marked this conversation as resolved
Outdated
|
||||
pub fn set_new_password(new_password: &str) -> Result<(), PeachError> {
|
||||
let new_password_hash = hash_password(&new_password.to_string());
|
||||
let result = set_admin_password_hash(&new_password_hash);
|
||||
|
@ -55,7 +55,7 @@ pub fn hash_password(password: &str) -> String {
|
|||
hasher.result_str()
|
||||
}
|
||||
|
||||
/// Uses htpasswd to set a new temporary password for the admin user
|
||||
/// Sets a new temporary password for the admin user
|
||||
notplants marked this conversation as resolved
Outdated
glyph
commented
Another small doc comment update needed here. Another small doc comment update needed here.
notplants
commented
thanks! stale comments are a source of great possible confusion thanks!
stale comments are a source of great possible confusion
|
||||
/// which can be used to reset the permanent password
|
||||
pub fn set_new_temporary_password(new_password: &str) -> Result<(), PeachError> {
|
||||
let new_password_hash = hash_password(&new_password.to_string());
|
||||
|
@ -82,7 +82,7 @@ pub fn verify_temporary_password(password: &str) -> Result<(), PeachError> {
|
|||
}
|
||||
}
|
||||
|
||||
/// generates a temporary password and sends it via ssb dm
|
||||
/// Generates a temporary password and sends it via ssb dm
|
||||
/// to the ssb id configured to be the admin of the peachcloud device
|
||||
pub fn send_password_reset() -> Result<(), PeachError> {
|
||||
// first generate a new random password of ascii characters
|
||||
|
@ -119,7 +119,6 @@ using this link: http://peach.local/reset_password",
|
|||
msg += &remote_link;
|
||||
// finally send the message to the admins
|
||||
let peach_config = load_peach_config()?;
|
||||
info!("sending password reset: {}", msg);
|
||||
for ssb_admin_id in peach_config.ssb_admin_ids {
|
||||
notplants marked this conversation as resolved
Outdated
glyph
commented
Lovely use of logging here 🖤 Lovely use of logging here :black_heart:
|
||||
sbot_client::private_message(&msg, &ssb_admin_id)?;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ pub enum LoginError {
|
|||
UserNotLoggedIn
|
||||
}
|
||||
|
||||
/// Request guard which returns an Authenticated struct with is_authenticated=true
|
||||
/// iff the user has a cookie which proves they are authenticated with peach-web.
|
||||
/// Request guard which returns an empty Authenticated struct from the request
|
||||
/// if and only if the user has a cookie which proves they are authenticated with peach-web.
|
||||
notplants marked this conversation as resolved
Outdated
glyph
commented
Tiny typo here on Tiny typo here on `iff`.
notplants
commented
"iff" is a shorthand that means "if and only if" (https://en.wikipedia.org/wiki/If_and_only_if), for now I changed the comment to say "if and only if", "iff" is a shorthand that means "if and only if" (https://en.wikipedia.org/wiki/If_and_only_if),
for now I changed the comment to say "if and only if",
but "iff" is a pretty useful acronym, gets used a fair amount in technical docs, maybe you will see it around more now.
glyph
commented
Oh wow, I had no idea! Thanks for pointing that out. Oh wow, I had no idea! Thanks for pointing that out.
|
||||
///
|
||||
/// Note that cookies.get_private uses encryption, which means that this private cookie
|
||||
/// cannot be inspected, tampered with, or manufactured by clients.
|
||||
|
@ -114,7 +114,6 @@ pub fn verify_login_form(login_form: LoginForm) -> Result<(), PeachError> {
|
|||
|
||||
#[post("/login", data="<login_form>")]
|
||||
pub fn login_post(login_form: Form<LoginForm>, cookies: &CookieJar<'_>) -> TemplateOrRedirect {
|
||||
info!("call to login post");
|
||||
let result = verify_login_form(login_form.into_inner());
|
||||
match result {
|
||||
Ok(_) => {
|
||||
|
|
Loading…
Reference in New Issue
Don't forget to update the doc comment here.