ORE Studio 0.0.4
Loading...
Searching...
No Matches
signup_service.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_IAM_SERVICE_SIGNUP_SERVICE_HPP
21#define ORES_IAM_SERVICE_SIGNUP_SERVICE_HPP
22
23#include <memory>
24#include <string>
25#include <expected>
26#include <boost/uuid/uuid.hpp>
27#include "ores.comms/messaging/message_types.hpp"
28#include "ores.iam/domain/account.hpp"
29#include "ores.iam/repository/account_repository.hpp"
30#include "ores.iam/repository/login_info_repository.hpp"
31#include "ores.iam/service/authorization_service.hpp"
32#include "ores.variability/service/system_flags_service.hpp"
33#include "ores.utility/uuid/uuid_v7_generator.hpp"
34#include "ores.logging/make_logger.hpp"
35
36namespace ores::iam::service {
37
42 bool success = false;
43 std::string error_message;
44 ores::utility::serialization::error_code error_code = ores::utility::serialization::error_code::none;
45 boost::uuids::uuid account_id;
46 std::string username;
47};
48
63private:
64 inline static std::string_view logger_name =
65 "ores.iam.service.signup_service";
66
67 [[nodiscard]] static auto& lg() {
68 using namespace ores::logging;
69 static auto instance = make_logger(logger_name);
70 return instance;
71 }
72
73public:
75
84 std::shared_ptr<variability::service::system_flags_service> system_flags,
85 std::shared_ptr<authorization_service> auth_service);
86
103 signup_result register_user(const std::string& username,
104 const std::string& email, const std::string& password);
105
111 bool is_signup_enabled() const;
112
113private:
114 repository::account_repository account_repo_;
115 repository::login_info_repository login_info_repo_;
116 std::shared_ptr<variability::service::system_flags_service> system_flags_;
117 std::shared_ptr<authorization_service> auth_service_;
118 utility::uuid::uuid_v7_generator uuid_generator_;
119};
120
121}
122
123#endif
Service layer for the IAM module.
Definition account_service.hpp:34
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:30
Reads and writes accounts off of data storage.
Definition account_repository.hpp:36
Reads and writes login tracking information off of data storage.
Definition login_info_repository.hpp:36
Result of a signup operation.
Definition signup_service.hpp:41
Service for user self-registration (signup).
Definition signup_service.hpp:62
signup_result register_user(const std::string &username, const std::string &email, const std::string &password)
Registers a new user account.
Definition signup_service.cpp:43
bool is_signup_enabled() const
Checks if signups are currently enabled.
Definition signup_service.cpp:177
A generator for UUID version 7 (v7) based on RFC 9562.
Definition uuid_v7_generator.hpp:50