chore: open userinfo constructor (#774)

This commit is contained in:
shuiyisong
2022-12-21 17:58:43 +08:00
committed by GitHub
parent 77182f5024
commit d0ebcc3b5a
2 changed files with 3 additions and 8 deletions

View File

@@ -69,7 +69,6 @@ impl UserInfo {
&self.username
}
#[cfg(test)]
pub fn new(username: impl Into<String>) -> Self {
Self {
username: username.into(),
@@ -165,9 +164,7 @@ pub mod test {
Password::PlainText(password) => {
if username == "greptime" {
if password == "greptime" {
return Ok(UserInfo {
username: "greptime".to_string(),
});
return Ok(UserInfo::new("greptime"));
} else {
return super::UserPasswordMismatchSnafu {
username: username.to_string(),

View File

@@ -113,9 +113,7 @@ impl UserProvider for StaticUserProvider {
match input_pwd {
Password::PlainText(pwd) => {
return if save_pwd == pwd.as_bytes() {
Ok(UserInfo {
username: username.to_string(),
})
Ok(UserInfo::new(username))
} else {
UserPasswordMismatchSnafu {
username: username.to_string(),
@@ -152,7 +150,7 @@ fn auth_mysql(
}
let candidate_stage_2 = sha1_one(&xor_result);
if candidate_stage_2 == hash_stage_2 {
Ok(UserInfo { username })
Ok(UserInfo::new(username))
} else {
UserPasswordMismatchSnafu { username }.fail()
}