30 lines
850 B
C++
30 lines
850 B
C++
#pragma once
|
|
|
|
#include <drogon/HttpRequest.h>
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace visione::auth
|
|
{
|
|
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 canOperateReports(const UserContext &user);
|
|
bool isAdmin(const UserContext &user);
|
|
bool mustChangePassword(const UserContext &user);
|
|
} // namespace visione::auth
|