35 lines
839 B
C++
35 lines
839 B
C++
#pragma once
|
|
|
|
#include "rublon/static_string.hpp"
|
|
#include <optional>
|
|
#include <rublon/stdlib.hpp>
|
|
|
|
namespace rublon {
|
|
|
|
class AuthenticationStatus {
|
|
public:
|
|
using tokenT = std::optional< StaticString< 64 > >;
|
|
enum class Action { Denied, Confirmed, Bypass };
|
|
|
|
AuthenticationStatus(Action action, const char * token = nullptr)
|
|
: _action{action}, _authenticationToken{token == nullptr ? tokenT{std::nullopt} : tokenT{token}} {}
|
|
|
|
constexpr bool userAuthorized() const {
|
|
return _action == Action::Confirmed;
|
|
}
|
|
|
|
Action action() const {
|
|
return _action;
|
|
}
|
|
|
|
std::string_view accessToken() const {
|
|
return {_authenticationToken->c_str(), _authenticationToken->size()};
|
|
}
|
|
|
|
private:
|
|
Action _action;
|
|
tokenT _authenticationToken; /// TODO dynamic mem
|
|
};
|
|
|
|
} // namespace rublon
|