add grants to UserInfo
@@ -18,6 +18,7 @@ use std::convert::TryFrom;
use common_exception::ErrorCode;
use common_exception::Result;
+use crate::user_grant::UserGrantSet;
use crate::AuthType;
use crate::UserPrivilege;
use crate::UserQuota;
@@ -37,7 +38,10 @@ pub struct UserInfo {
pub auth_type: AuthType,
#[serde(default)]
- pub privileges: UserPrivilege,
+ pub privileges: UserPrivilege, // TODO: remove this field after the grants field take effects
+
+ #[serde(default)]
+ pub grants: UserGrantSet,
#[serde(default)]
pub quota: UserQuota,
@@ -47,6 +51,7 @@ impl UserInfo {
pub fn new(name: String, hostname: String, password: Vec<u8>, auth_type: AuthType) -> Self {
// Default is no privileges.
let privileges = UserPrivilege::empty();
+ let grants = UserGrantSet::default();
let quota = UserQuota::no_limit();
UserInfo {
@@ -55,10 +60,12 @@ impl UserInfo {
password,
auth_type,
privileges,
+ grants,
quota,
}
}
+ // TODO: remove this after grants field take effects
pub fn set_privileges(&mut self, privileges: UserPrivilege) {
self.privileges |= privileges;
}
