#include <Session.h>
Definition at line 24 of file Session.h.
◆ Session()
Definition at line 88 of file Session.C.
89{
90 auto sqlite3 = std::make_unique<Dbo::backend::Sqlite3>(WApplication::instance()->
appRoot() +
"hangman.db");
91 sqlite3->setProperty(
"show-queries",
"true");
93
96 session_.mapClass<AuthInfo::AuthIdentityType>(
"auth_identity");
97 session_.mapClass<AuthInfo::AuthTokenType>(
"auth_token");
98
100
102 try {
104
105
106
107
109 guestUser.addIdentity(Auth::Identity::LoginName,
"guest");
111
112 log(
"info") <<
"Database created";
113 } catch (...) {
114 log(
"info") <<
"Using existing database";
115 }
116
118}
Wt::Auth::Dbo::UserDatabase< AuthInfo > UserDatabase
Wt::Auth::Dbo::AuthInfo< User > AuthInfo
std::unique_ptr< UserDatabase > users_
Wt::Dbo::Session session_
◆ addToScore()
Definition at line 144 of file Session.C.
145{
147
148 dbo::ptr<User>
u =
user();
150 u.modify()->score +=
s;
151 ++
u.modify()->gamesPlayed;
152 u.modify()->lastGame = WDateTime::currentDateTime();
153 }
154
156}
Wt::Dbo::ptr< User > user() const
◆ auth()
const Auth::AuthService & Session::auth |
( |
| ) |
|
|
static |
◆ configureAuth()
void Session::configureAuth |
( |
| ) |
|
|
static |
Definition at line 65 of file Session.C.
66{
69
70 auto verifier = std::make_unique<Auth::PasswordVerifier>();
71 verifier->addHashFunction(std::make_unique<Auth::BCryptHashFunction>(7));
72
73#ifdef HAVE_CRYPT
74
75
76 verifier->addHashFunction(std::make_unique<UnixCryptHashFunction>());
77#endif
78
80 myPasswordService.setStrengthValidator(std::make_unique<Auth::PasswordStrengthValidator>());
82
83 if (Auth::GoogleService::configured()) {
85 }
86}
◆ findRanking()
int Session::findRanking |
( |
| ) |
|
Definition at line 180 of file Session.C.
181{
183
184 dbo::ptr<User>
u =
user();
186
188 ranking =
session_.query<
int>(
"select distinct count(score) from user")
189 .
where(
"score > ?").bind(
u->score);
190
192
194}
◆ login()
Wt::Auth::Login & Session::login |
( |
| ) |
|
|
inline |
◆ oAuth()
std::vector< const Auth::OAuthService * > Session::oAuth |
( |
| ) |
|
|
static |
Definition at line 211 of file Session.C.
212{
213 std::vector<const Auth::OAuthService *>
result;
217 }
219}
◆ passwordAuth()
const Auth::AbstractPasswordService & Session::passwordAuth |
( |
| ) |
|
|
static |
◆ topUsers()
std::vector< User > Session::topUsers |
( |
int | limit | ) |
|
Definition at line 158 of file Session.C.
159{
161
163
165 for (Users::const_iterator
i =
top.begin();
i !=
top.end(); ++
i) {
166 dbo::ptr<User>
user = *
i;
168
170 std::string name =
auth->identity(Auth::Identity::LoginName).toUTF8();
171
172 result.back().name = name;
173 }
174
176
178}
dbo::collection< dbo::ptr< User > > Users
static const Wt::Auth::AuthService & auth()
dbo::weak_ptr< AuthInfo > authInfo
◆ user()
dbo::ptr< User > Session::user |
( |
| ) |
const |
|
private |
Definition at line 120 of file Session.C.
121{
123 dbo::ptr<AuthInfo> authInfo =
users_->find(
login_.user());
124 dbo::ptr<User>
user = authInfo->user();
125
128 authInfo.modify()->setUser(
user);
129 }
130
132 } else
133 return dbo::ptr<User>();
134}
◆ userName()
std::string Session::userName |
( |
| ) |
const |
Definition at line 136 of file Session.C.
137{
139 return login_.user().identity(Auth::Identity::LoginName).toUTF8();
140 else
141 return std::string();
142}
◆ users()
Auth::AbstractUserDatabase & Session::users |
( |
| ) |
|
◆ login_
Wt::Auth::Login Session::login_ |
|
private |
◆ session_
Wt::Dbo::Session Session::session_ |
|
mutableprivate |
◆ users_
The documentation for this class was generated from the following files: