Typesafe lookup

This commit is contained in:
moznion
2020-11-28 18:29:37 +09:00
parent 09a82d3454
commit a20f1a1d28
5 changed files with 256 additions and 178 deletions
+2 -8
View File
@@ -46,14 +46,8 @@ impl RequestHandler<(), io::Error> for MyRequestHandler {
let maybe_user_name_attr = rfc2865::lookup_user_name(req_packet);
let maybe_user_password_attr = rfc2865::lookup_user_password(req_packet);
let user_name = maybe_user_name_attr.unwrap().decode_string().unwrap();
let user_password = String::from_utf8(
maybe_user_password_attr
.unwrap()
.decode_user_password(req_packet.get_secret(), req_packet.get_authenticator())
.unwrap(),
)
.unwrap();
let user_name = maybe_user_name_attr.unwrap().unwrap();
let user_password = String::from_utf8(maybe_user_password_attr.unwrap().unwrap()).unwrap();
let code = if user_name == "admin" && user_password == "p@ssw0rd" {
Code::AccessAccept
} else {