给passwd指令添加权限校验

This commit is contained in:
2023-12-14 06:50:38 +00:00
parent 62c7111537
commit 21793ba0e6

View File

@ -171,7 +171,10 @@ std::vector<std::string> BookStoreEngineClass::ExecutePasswd(
if (!CommandPasswdLexer(cmd, user_id, current_password, new_password))
return std::vector<std::string>({"Invalid"});
// debugPrint("sucessfully lexed passwd");
if (user_data_base.GetPrevilege(user_id) < 1)
if (user_data_base.GetPrevilege(user_id) == -1)
return std::vector<std::string>({"Invalid"});
if (login_stack.empty() ||
user_data_base.GetPrevilege(login_stack.top().first) < 1)
return std::vector<std::string>({"Invalid"});
// debugPrint("begin checing authority");
if (login_stack.size() > 0 &&