1 // This may look like C code, but it's really -*- C++ -*-
2 /*
3  * Copyright (C) 2009 Emweb bv, Herent, Belgium.
4  *
5  * See the LICENSE file for terms of use.
6  */
7 #ifndef SESSION_H_
8 #define SESSION_H_
9 
10 #include <Wt/Auth/Login.h>
11 
12 #include <Wt/Dbo/Session.h>
13 #include <Wt/Dbo/ptr.h>
14 
15 #include "User.h"
16 
17 using namespace Wt;
18 
19 namespace dbo = Dbo;
20 
21 typedef Auth::Dbo::UserDatabase<AuthInfo> UserDatabase;
22 
23 class QRAuthService;
24 class QRTokenDatabase;
25 
26 class Session : public dbo::Session
27 {
28 public:
29   static void configureAuth();
30 
31   Session(const std::string& sqliteDb);
32   ~Session();
33 
34   dbo::ptr<User> user() const;
35 
36   Auth::AbstractUserDatabase& users();
37   QRTokenDatabase& qrTokenDatabase();
login()38   Auth::Login& login() { return login_; }
39 
40   static const Auth::AuthService& auth();
41   static const Auth::PasswordService& passwordAuth();
42   static const QRAuthService& qrAuth();
43   static const std::vector<const Auth::OAuthService *>& oAuth();
44 
45 private:
46   std::unique_ptr<UserDatabase> users_;
47   std::unique_ptr<QRTokenDatabase> qrTokens_;
48   Auth::Login login_;
49 };
50 
51 #endif // SESSION_H_
52