This commit is contained in:
Hubert 2021-07-21 07:03:27 +02:00
parent 90bc6d6d4f
commit 9af4fa56e1
1 changed files with 17 additions and 2 deletions

View File

@ -1,6 +1,21 @@
use actix_web_httpauth::extractors::basic::BasicAuth;
use std::borrow::Cow;
pub fn check_user(name : String, pwd : String) -> bool {
pwd.eq(&(name + "pwd")) //stub!
pub trait AuthValidator {
fn check_user(&self, name : &String, pwd : &String) -> bool;
fn check_basic(&self, basic : BasicAuth) -> bool {
match basic.password() {
None => {false}
Some(pwd) => {self.check_user(&basic.user_id().to_string(), &pwd.to_string())}
}
}
}
pub struct TestValidator;
impl AuthValidator for TestValidator {
fn check_user(&self, name: &String, pwd: &String) -> bool {
pwd.eq(&(name.clone() + "pwd")) //stub!
}
}