Wt examples: hangman/Session.h Source File

Wt examples 4.10.4

Loading...
Searching...
No Matches
Session.h
Go to the documentation of this file.
1// This may look like C code, but it's really -*- C++ -*-
2/*
3 * Copyright (C) 2011 Emweb bv, Herent, Belgium.
4 *
5 * See the LICENSE file for terms of use.
6 */
7
8#ifndef SESSION_H_
9#define SESSION_H_
10
11#include <vector>
12
13#include <Wt/Auth/Login.h>
14#include <Wt/Auth/Dbo/UserDatabase.h>
15
16#include <Wt/Dbo/Session.h>
17#include <Wt/Dbo/ptr.h>
18#include <Wt/Dbo/backend/Sqlite3.h>
19
20#include "User.h"
21
22 using UserDatabase = Wt::Auth::Dbo::UserDatabase<AuthInfo>;
23
24 class Session
25{
26public:
27 static void configureAuth();
28
29 Session();
30
31 Wt::Auth::AbstractUserDatabase& users();
32 Wt::Auth::Login& login() { return login_; }
33
34 std::vector<User> topUsers(int limit);
35
36 /*
37 * These methods deal with the currently logged in user
38 */
39 std::string userName() const;
40 int findRanking();
41 void addToScore(int s);
42
43 static const Wt::Auth::AuthService& auth();
44 static const Wt::Auth::AbstractPasswordService& passwordAuth();
45 static std::vector<const Wt::Auth::OAuthService *> oAuth();
46
47private:
48 mutable Wt::Dbo::Session session_;
49 std::unique_ptr<UserDatabase> users_;
50 Wt::Auth::Login login_;
51
52 Wt::Dbo::ptr<User> user() const;
53};
54
55#endif //SESSION_H_
UserDatabase
Wt::Auth::Dbo::UserDatabase< AuthInfo > UserDatabase
Definition Session.h:22
User.h
Session
Definition Session.h:25
Session::configureAuth
static void configureAuth()
Definition Session.C:65
Session::passwordAuth
static const Wt::Auth::AbstractPasswordService & passwordAuth()
Definition Session.C:206
Session::users_
std::unique_ptr< UserDatabase > users_
Definition Session.h:49
Session::topUsers
std::vector< User > topUsers(int limit)
Definition Session.C:158
Session::login_
Wt::Auth::Login login_
Definition Session.h:50
Session::userName
std::string userName() const
Definition Session.C:136
Session::session_
Wt::Dbo::Session session_
Definition Session.h:48
Session::auth
static const Wt::Auth::AuthService & auth()
Definition Session.C:201
Session::user
Wt::Dbo::ptr< User > user() const
Definition Session.C:120
Session::findRanking
int findRanking()
Definition Session.C:180
Session::Session
Session()
Definition Session.C:88
Session::oAuth
static std::vector< const Wt::Auth::OAuthService * > oAuth()
Definition Session.C:211
Session::login
Wt::Auth::Login & login()
Definition Session.h:32
Session::users
Wt::Auth::AbstractUserDatabase & users()
Definition Session.C:196
Session::addToScore
void addToScore(int s)
Definition Session.C:144