Mercurial > crates > nonstick
comparison testharness/src/lib.rs @ 168:6642e89d29a2
more closely follow real password change flow
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Tue, 15 Jul 2025 00:56:01 -0400 |
parents | 0cabe7b94a4f |
children | 77470e45e397 |
comparison
equal
deleted
inserted
replaced
167:0cabe7b94a4f | 168:6642e89d29a2 |
---|---|
89 match action { | 89 match action { |
90 AuthtokAction::PreliminaryCheck => { | 90 AuthtokAction::PreliminaryCheck => { |
91 if handle.old_authtok(None)?.as_bytes() != b"old token!" { | 91 if handle.old_authtok(None)?.as_bytes() != b"old token!" { |
92 return Err(ErrorCode::AuthenticationError); | 92 return Err(ErrorCode::AuthenticationError); |
93 } | 93 } |
94 Ok(()) | |
95 } | |
96 AuthtokAction::Update => { | |
94 let password = handle.authtok(None)?; | 97 let password = handle.authtok(None)?; |
95 if password.as_bytes() != b"acceptable" { | 98 if password.as_bytes() != b"acceptable" { |
96 return Err(ErrorCode::PermissionDenied); | 99 return Err(ErrorCode::PermissionDenied); |
97 } | |
98 handle.set_module_data("checked_pass", password) | |
99 } | |
100 AuthtokAction::Update => { | |
101 let password = handle.authtok(None)?; | |
102 let checked: &OsString = handle | |
103 .get_module_data("checked_pass") | |
104 .ok_or(ErrorCode::SystemError)?; | |
105 if password != *checked { | |
106 error!(handle, "password mismatch? {password:?} {checked:?}"); | |
107 return Err(ErrorCode::AuthenticationError); | |
108 } | 100 } |
109 Ok(()) | 101 Ok(()) |
110 } | 102 } |
111 } | 103 } |
112 } | 104 } |