почти рабочая авторизация. оказывается сейчас нет payload у запроса, поэтому невозможно распарсить из него json.
This commit is contained in:
@@ -9,20 +9,25 @@ namespace http::auth {
|
||||
*/
|
||||
class User {
|
||||
private:
|
||||
uint32_t perms;
|
||||
uint32_t perms{};
|
||||
|
||||
public:
|
||||
const std::string username;
|
||||
std::string passwordHash;
|
||||
|
||||
User(const std::string& username, const std::string& passwordHash);
|
||||
/**
|
||||
* Конструктор пользователя.
|
||||
* @param username Имя пользователя, он же - логин.
|
||||
* @param passwordHash Хеш sha256 пароля пользователя. Если передать пустой, то пароль будет сгенерирован такой же, как и имя пользователя.
|
||||
*/
|
||||
explicit User(const std::string& username, const std::string& passwordHash = "");
|
||||
|
||||
/**
|
||||
* Проверить пароль на соответствие хешу
|
||||
* @param pass
|
||||
* @return
|
||||
*/
|
||||
bool checkPassword(const std::string& pass);
|
||||
bool checkPassword(const std::string& pass) const;
|
||||
|
||||
/**
|
||||
* Установка пароля
|
||||
@@ -43,7 +48,7 @@ namespace http::auth {
|
||||
* @param p набор прав, из констант данного класса.
|
||||
* @return
|
||||
*/
|
||||
bool checkPremisions(uint32_t p);
|
||||
bool checkPremisions(uint32_t p) const;
|
||||
|
||||
void setPremisions(uint32_t p);
|
||||
void resetPremisions(uint32_t p);
|
||||
@@ -65,9 +70,11 @@ namespace http::auth {
|
||||
* @param rep
|
||||
* @return true, в случае успешной авторизации
|
||||
*/
|
||||
bool doAuth(const std::string& username, const std::string& password, server::Reply& rep);
|
||||
std::shared_ptr<http::auth::User> doAuth(const std::string &username, const std::string &password, server::Reply &rep);
|
||||
|
||||
std::shared_ptr<User> getSession(server::Request& req);
|
||||
std::vector<std::shared_ptr<User>> users;
|
||||
|
||||
std::shared_ptr<User> getSession(const server::Request &req);
|
||||
|
||||
~AuthProvider();
|
||||
};
|
||||
|
Reference in New Issue
Block a user