|
|
@ -27,9 +27,9 @@ void UserMgrService::login(shared_ptr<MsgProcessContext> cxt, string uid, string |
|
|
|
} |
|
|
|
|
|
|
|
if (!m_db->isUserExist(uid)) //
|
|
|
|
THROW_APP_EXCEPTION(err::kappe_user_not_exist, fmt::format("user {} not exist", uid)); |
|
|
|
THROW_APP_EXCEPTION(err::kappe_user_not_exist, ""); |
|
|
|
if (!m_db->ispasswdCorrect(uid, pwd)) //
|
|
|
|
THROW_APP_EXCEPTION(err::kappe_passwd_error, fmt::format("user {} passwd error", uid)); |
|
|
|
THROW_APP_EXCEPTION(err::kappe_passwd_error, ""); |
|
|
|
|
|
|
|
m_deviceStateService->setLoginState(uid, m_db->getUser(uid)->is_admin); |
|
|
|
logger->info("user {} login success", uid); |
|
|
@ -44,7 +44,6 @@ void UserMgrService::unlogin(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
return; |
|
|
|
} |
|
|
|
void UserMgrService::chpasswd(shared_ptr<MsgProcessContext> cxt, string uid, string newpasswd, string passwd) { |
|
|
|
|
|
|
|
if (!m_deviceStateService->isLoginAdmin()) { |
|
|
|
APPCHECK(!m_db->ispasswdCorrect(uid, passwd), err::kappe_passwd_error, fmt::format("user {} passwd error", uid)); |
|
|
|
} |
|
|
@ -52,9 +51,7 @@ void UserMgrService::chpasswd(shared_ptr<MsgProcessContext> cxt, string uid, str |
|
|
|
logger->info("changet passwd {} {}", uid, passwd); |
|
|
|
auto user = m_db->changePasswd(uid, newpasswd); |
|
|
|
} |
|
|
|
void UserMgrService::addUser(shared_ptr<MsgProcessContext> cxt, string uid, string passwd) { |
|
|
|
m_db->addUser(uid, passwd); |
|
|
|
} |
|
|
|
void UserMgrService::addUser(shared_ptr<MsgProcessContext> cxt, string uid, string passwd) { m_db->addUser(uid, passwd); } |
|
|
|
void UserMgrService::delUser(shared_ptr<MsgProcessContext> cxt, int id) { |
|
|
|
auto user = m_db->delUser(id); |
|
|
|
APPCHECK(!user, err::kappe_user_not_exist, fmt::format("user {} not exist", id)); |
|
|
@ -66,7 +63,7 @@ void UserMgrService::updateUserUid(shared_ptr<MsgProcessContext> cxt, int id, st |
|
|
|
APPCHECK(!user, err::kappe_user_not_exist, fmt::format("user {} not exist", id)); |
|
|
|
} |
|
|
|
void UserMgrService::getAllUser(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
auto users = m_db->getAllUserJson(); |
|
|
|
auto users = m_db->getAllUserJson(); |
|
|
|
cxt->receipt["rely"] = users; |
|
|
|
return; |
|
|
|
} |
|
|
|