ORE Studio 0.0.4
Loading...
Searching...
No Matches
session_manager.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_WT_SERVICE_SESSION_MANAGER_HPP
21#define ORES_WT_SERVICE_SESSION_MANAGER_HPP
22
23#include <string>
24#include <optional>
25#include <boost/uuid/uuid.hpp>
26#include <boost/asio/ip/address.hpp>
27
28namespace ores::wt::service {
29
34 bool success = false;
35 std::string error_message;
36 boost::uuids::uuid account_id;
37 std::string username;
38 std::string email;
39 bool password_reset_required = false;
40};
41
46 boost::uuids::uuid account_id;
47 std::string username;
48 std::string email;
49};
50
58public:
60
61 login_result login(const std::string& username, const std::string& password,
62 const std::string& client_ip);
63
64 void logout();
65
66 bool is_logged_in() const { return session_.has_value(); }
67
68 const std::optional<session_data>& session() const { return session_; }
69
70 bool has_permission(const std::string& permission) const;
71
72 login_result create_bootstrap_admin(const std::string& username,
73 const std::string& email,
74 const std::string& password);
75
76private:
77 std::optional<session_data> session_;
78};
79
80}
81
82#endif
Result of a login attempt.
Definition session_manager.hpp:33
Current session information.
Definition session_manager.hpp:45
Manages user authentication sessions for a single Wt application.
Definition session_manager.hpp:57