#include <Session.h>
|
static void | configureAuth () |
|
static const Wt::Auth::AuthService & | auth () |
|
static const Wt::Auth::AbstractPasswordService & | passwordAuth () |
|
static const std::vector< const Wt::Auth::OAuthService * > & | oAuth () |
|
Definition at line 23 of file Session.h.
◆ Session()
Definition at line 98 of file Session.C.
99 :
sqlite3_(WApplication::instance()->appRoot() +
"hangman.db")
102 sqlite3_.setProperty(
"show-queries",
"true");
106 session_.mapClass<AuthInfo::AuthIdentityType>(
"auth_identity");
107 session_.mapClass<AuthInfo::AuthTokenType>(
"auth_token");
111 dbo::Transaction transaction(
session_);
118 Auth::User guestUser =
users_->registerNew();
119 guestUser.addIdentity(Auth::Identity::LoginName,
"guest");
120 myPasswordService.updatePassword(guestUser,
"guest");
122 Wt::log(
"info") <<
"Database created";
124 Wt::log(
"info") <<
"Using existing database";
127 transaction.commit();
◆ ~Session()
◆ addToScore()
void Session::addToScore |
( |
int |
s | ) |
|
Definition at line 159 of file Session.C.
161 dbo::Transaction transaction(
session_);
163 dbo::ptr<User> u =
user();
165 u.modify()->score += s;
166 ++u.modify()->gamesPlayed;
167 u.modify()->lastGame = WDateTime::currentDateTime();
170 transaction.commit();
◆ auth()
const Auth::AuthService & Session::auth |
( |
| ) |
|
|
static |
Definition at line 216 of file Session.C.
218 return myAuthService;
◆ configureAuth()
void Session::configureAuth |
( |
| ) |
|
|
static |
Definition at line 76 of file Session.C.
78 myAuthService.setAuthTokensEnabled(
true,
"hangmancookie");
79 myAuthService.setEmailVerificationEnabled(
true);
81 Auth::PasswordVerifier *verifier =
new Auth::PasswordVerifier();
82 verifier->addHashFunction(
new Auth::BCryptHashFunction(7));
87 verifier->addHashFunction(
new UnixCryptHashFunction());
90 myPasswordService.setVerifier(verifier);
91 myPasswordService.setStrengthValidator(
new Auth::PasswordStrengthValidator());
92 myPasswordService.setAttemptThrottlingEnabled(
true);
94 if (Auth::GoogleService::configured())
95 myOAuthServices.push_back(
new Auth::GoogleService(myAuthService));
◆ findRanking()
int Session::findRanking |
( |
| ) |
|
Definition at line 195 of file Session.C.
197 dbo::Transaction transaction(
session_);
199 dbo::ptr<User> u =
user();
203 ranking =
session_.query<
int>(
"select distinct count(score) from user")
204 .where(
"score > ?").bind(u->score);
206 transaction.commit();
◆ login()
Wt::Auth::Login& Session::login |
( |
| ) |
|
|
inline |
◆ oAuth()
const std::vector< const Auth::OAuthService * > & Session::oAuth |
( |
| ) |
|
|
static |
Definition at line 226 of file Session.C.
228 return myOAuthServices;
◆ passwordAuth()
const Auth::AbstractPasswordService & Session::passwordAuth |
( |
| ) |
|
|
static |
Definition at line 221 of file Session.C.
223 return myPasswordService;
◆ topUsers()
std::vector< User > Session::topUsers |
( |
int |
limit | ) |
|
Definition at line 173 of file Session.C.
175 dbo::Transaction transaction(
session_);
179 std::vector<User> result;
180 for (Users::const_iterator i = top.begin(); i != top.end(); ++i) {
181 dbo::ptr<User>
user = *i;
182 result.push_back(*
user);
184 dbo::ptr<AuthInfo>
auth = *
user->authInfos.begin();
185 std::string name =
auth->identity(Auth::Identity::LoginName).toUTF8();
187 result.back().name = name;
190 transaction.commit();
◆ user()
dbo::ptr< User > Session::user |
( |
| ) |
const |
|
private |
Definition at line 135 of file Session.C.
138 dbo::ptr<AuthInfo> authInfo =
users_->find(
login_.user());
139 dbo::ptr<User>
user = authInfo->user();
143 authInfo.modify()->setUser(
user);
148 return dbo::ptr<User>();
◆ userName()
std::string Session::userName |
( |
| ) |
const |
Definition at line 151 of file Session.C.
154 return login_.user().identity(Auth::Identity::LoginName).toUTF8();
156 return std::string();
◆ users()
Auth::AbstractUserDatabase & Session::users |
( |
| ) |
|
◆ login_
Wt::Auth::Login Session::login_ |
|
private |
◆ session_
Wt::Dbo::Session Session::session_ |
|
mutableprivate |
◆ sqlite3_
Wt::Dbo::backend::Sqlite3 Session::sqlite3_ |
|
private |
◆ users_
The documentation for this class was generated from the following files: