code_device/hgdriver/hgdev/user-opt/user.cpp

53 lines
1.0 KiB
C++
Raw Permalink Normal View History

2023-09-21 03:24:44 +00:00
#include "user.h"
#include <huagao/brand.h>
#include <huagao/hgscanner_error.h>
#include <sane/sane_ex.h>
2023-09-21 03:24:44 +00:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// memory management ...
hguser::hguser() : name_(""), pwd_(""), priv_(USER_PRIVILEGE_COMMON)
{}
hguser::~hguser()
{}
// name and password should encrypt here, FIXED me ...
int hguser::login(const char* name, const char* pwd)
{
name_ = name;
pwd_ = pwd;
if (name_ == ADMIN_NAME && pwd_ == ADMIN_PWD)
priv_ = USER_PRIVILEGE_LOCAL_MGR;
else
{
// higher privilege checks must be more complex, to be implementing ...
}
return SCANNER_ERR_OK;
2023-09-21 03:24:44 +00:00
}
int hguser::logout(const char* name, const char* pwd)
{
if (name == name && pwd_ == pwd)
{
name = "";
pwd_ = "";
priv_ = USER_PRIVILEGE_COMMON;
return 0;
}
else
{
return SCANNER_ERR_ACCESS_DENIED;
}
}
bool hguser::has_privilege(int priv)
{
2023-11-13 02:29:39 +00:00
//return (priv & priv_) == priv;
return priv <= priv_;
2023-09-21 03:24:44 +00:00
}