OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
MongoUserFunctions.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <cstdint>
5#include <iostream>
6#include <vector>
7#include <bsoncxx/json.hpp>
8#include <bsoncxx/types.hpp>
9#include <mongocxx/client.hpp>
10#include <mongocxx/stdx.hpp>
11#include <mongocxx/uri.hpp>
12#include <mongocxx/instance.hpp>
13#include <bsoncxx/builder/stream/helpers.hpp>
14#include <bsoncxx/builder/stream/document.hpp>
15#include <bsoncxx/builder/stream/array.hpp>
16
18
19#include "MongoConstants.h"
20#include "User.h"
21
22using bsoncxx::builder::stream::close_array;
23using bsoncxx::builder::stream::close_document;
24using bsoncxx::builder::stream::document;
25using bsoncxx::builder::stream::finalize;
26using bsoncxx::builder::stream::open_array;
27using bsoncxx::builder::stream::open_document;
28using bsoncxx::document::value;
29using bsoncxx::document::view;
30using bsoncxx::document::element;
31
32
34{
35 bool authenticateUser(std::string username, std::string password, std::string databaseUrl, mongocxx::client& adminClient);
36
37 bool registerUser(std::string username, std::string password, mongocxx::client& adminClient, std::string oldSettingsCollectionName = "");
38
39 std::string generateUserSettingsCollectionName(mongocxx::client& adminClient);
40
41 User getUserDataThroughUsername(const std::string& username, mongocxx::client& adminClient);
42
43 User getUserDataThroughId(std::string userId, mongocxx::client& adminClient);
44
45 std::vector<User> getAllUsers(mongocxx::client& adminClient);
46 size_t getAllUserCount(mongocxx::client& adminClient);
47
48 bool removeUser(User& userToBeDeleted, mongocxx::client& adminClient);
49
50 bool updateUserUsernameById(std::string userId, std::string newUsername, mongocxx::client& adminClient);
51
52 bool updateUserUsernameByName(std::string oldUsername, std::string newUsername, mongocxx::client& adminClient);
53
54 bool changeUserPassword(std::string username, std::string newPassword, mongocxx::client& adminClient);
55
56 bool updateUsername(std::string oldUsername, std::string newUsername, mongocxx::client& adminClient);
57
58 std::string userToJson(User& user);
59 std::string usersToJson(std::vector<User>& users);
60
61 std::string hashPassword(const std::string &password);
62
63 bool doesUserExist(const std::string &userName, mongocxx::client& adminClient);
64
65 void createTmpUser(std::string userName, std::string userPWD, User& _loggedInUser, mongocxx::client& adminClient, ot::JsonDocument &json);
66 void removeTmpUser(std::string userName, mongocxx::client& adminClient);
67}
std::map< int, std::string > users
Definition UserAPI.cpp:10
Definition User.h:20
JSON document.
Definition JSON.h:276
Definition MongoUserFunctions.h:34
User getUserDataThroughId(std::string userId, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:225
bool authenticateUser(std::string username, std::string password, std::string databaseUrl, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:31
void createTmpUser(std::string userName, std::string userPWD, User &_loggedInUser, mongocxx::client &adminClient, ot::JsonDocument &json)
Definition MongoUserFunctions.cpp:516
size_t getAllUserCount(mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:271
std::vector< User > getAllUsers(mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:245
bool registerUser(std::string username, std::string password, mongocxx::client &adminClient, std::string oldSettingsCollectionName="")
Definition MongoUserFunctions.cpp:67
bool updateUsername(std::string oldUsername, std::string newUsername, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:454
bool removeUser(User &userToBeDeleted, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:281
std::string userToJson(User &user)
Definition MongoUserFunctions.cpp:493
bool updateUserUsernameByName(std::string oldUsername, std::string newUsername, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:380
bool updateUserUsernameById(std::string userId, std::string newUsername, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:341
bool changeUserPassword(std::string username, std::string newPassword, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:419
bool doesUserExist(const std::string &userName, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:324
std::string generateUserSettingsCollectionName(mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:166
std::string hashPassword(const std::string &password)
Definition MongoUserFunctions.cpp:154
User getUserDataThroughUsername(const std::string &username, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:204
void removeTmpUser(std::string userName, mongocxx::client &adminClient)
Definition MongoUserFunctions.cpp:547
std::string usersToJson(std::vector< User > &users)
Definition MongoUserFunctions.cpp:502