Add user authorization
This commit is contained in:
+6
-1
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace visione::auth
|
||||
{
|
||||
@@ -12,12 +13,16 @@ struct UserContext
|
||||
long long id{0};
|
||||
std::string email;
|
||||
std::string role;
|
||||
std::vector<std::string> roles;
|
||||
std::vector<std::string> permissions;
|
||||
bool mustChangePassword{false};
|
||||
};
|
||||
|
||||
std::optional<std::string> bearerToken(const drogon::HttpRequestPtr &request);
|
||||
std::optional<UserContext> authenticate(const drogon::HttpRequestPtr &request);
|
||||
bool hasRole(const UserContext &user, const std::string &role);
|
||||
bool hasPermission(const UserContext &user, const std::string &permission);
|
||||
bool canManageReports(const UserContext &user);
|
||||
bool isAdmin(const UserContext &user);
|
||||
bool mustChangePassword(const UserContext &user);
|
||||
} // namespace visione::auth
|
||||
|
||||
|
||||
Reference in New Issue
Block a user