SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AuthDBSyncContext.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2018 SEGS Team (see Authors.txt)
5  * This software is licensed! (See License.txt for details)
6  */
7 
8 #pragma once
9 #include <memory>
10 
11 class QSqlDatabase;
12 class QSqlQuery;
13 class QSqlError;
14 class QString;
15 
16 struct CreateAccountData;
21 
26 {
27  static constexpr int required_db_version = 0;
28  std::unique_ptr<QSqlDatabase> m_db;
29  std::unique_ptr<QSqlQuery> m_add_account_query;
30  std::unique_ptr<QSqlQuery> m_prepared_select_account_by_id;
31  std::unique_ptr<QSqlQuery> m_prepared_select_account_passw;
32  std::unique_ptr<QSqlQuery> m_prepared_select_account_by_username;
33  std::unique_ptr<QSqlError> last_error;
34  bool m_setup_complete = false;
35 
36 public:
39  QSqlError *getLastError() const { return last_error.get(); }
40  bool loadAndConfigure();
41  bool addAccount(const struct CreateAccountData &data);
43 // bool retrieveAccount(const RetrieveAccountRequestData &data, RetrieveAccountResponseData &result);
45 protected:
46  bool checkPassword(const QString &login, const QString &password);
47 private:
48  int64_t getDbVersion(QSqlDatabase &db);
49 };
bool retrieveAccountAndCheckPassword(const RetrieveAccountRequestData &data, RetrieveAccountResponseData &result)
Definition: AuthDBSyncContext.cpp:207
~AuthDbSyncContext()
Definition: AuthDBSyncContext.cpp:44
Definition: AuthDBSyncEvents.h:90
Definition: AuthDBSyncEvents.h:82
bool getPasswordValidity(const ValidatePasswordRequestData &data, ValidatePasswordResponseData &result)
Definition: AuthDBSyncContext.cpp:231
Definition: AuthDBSyncEvents.h:70
bool loadAndConfigure()
Definition: AuthDBSyncContext.cpp:62
QSqlError * getLastError() const
Definition: AuthDBSyncContext.h:39
The AuthDbSyncContext class is used as thread local storage for auth database related objects...
Definition: AuthDBSyncContext.h:25
Definition: AuthDBSyncEvents.h:56
bool checkPassword(const QString &login, const QString &password)
Definition: AuthDBSyncContext.cpp:186
bool addAccount(const struct CreateAccountData &data)
Definition: AuthDBSyncContext.cpp:144
i32 login(string login, string passw)
Definition: AuthDBSyncEvents.h:96
AuthDbSyncContext()
Definition: AuthDBSyncContext.cpp:42