2024-11-01 19:05:20 +08:00
|
|
|
#ifndef __BLOGUSERDATABASE_H__
|
|
|
|
#define __BLOGUSERDATABASE_H__
|
|
|
|
|
|
|
|
#include <Wt/Auth/AbstractUserDatabase.h>
|
|
|
|
#include <Wt/Dbo/Transaction.h>
|
|
|
|
#include <Wt/Dbo/Types.h>
|
|
|
|
|
|
|
|
class User;
|
|
|
|
|
|
|
|
class BlogUserDatabase : public Wt::Auth::AbstractUserDatabase {
|
|
|
|
public:
|
|
|
|
BlogUserDatabase(Wt::Dbo::Session &session);
|
|
|
|
~BlogUserDatabase();
|
2024-11-02 00:30:14 +08:00
|
|
|
Wt::Dbo::ptr<User> find(const Wt::Auth::User &user) const;
|
2024-11-03 22:31:23 +08:00
|
|
|
Wt::Auth::User find(Wt::Dbo::ptr<User> user) const;
|
2024-11-02 00:30:14 +08:00
|
|
|
|
2024-11-01 19:05:20 +08:00
|
|
|
Transaction *startTransaction() final;
|
|
|
|
Wt::Auth::User findWithId(const std::string &id) const final;
|
|
|
|
Wt::Auth::User findWithIdentity(const std::string &provider, const Wt::WString &identity) const final;
|
|
|
|
void addIdentity(const Wt::Auth::User &user, const std::string &provider, const Wt::WString &identity) final;
|
|
|
|
void removeIdentity(const Wt::Auth::User &user, const std::string &provider) final;
|
|
|
|
Wt::WString identity(const Wt::Auth::User &user, const std::string &provider) const final;
|
|
|
|
void setLastLoginAttempt(const Wt::Auth::User &user, const Wt::WDateTime &t) final;
|
2024-11-03 22:31:23 +08:00
|
|
|
Wt::Auth::PasswordHash password(const Wt::Auth::User &user) const final;
|
2024-11-01 19:05:20 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
struct WithUser {
|
|
|
|
WithUser(const BlogUserDatabase &self, const Wt::Auth::User &user);
|
|
|
|
~WithUser();
|
|
|
|
|
|
|
|
Wt::Dbo::Transaction transaction;
|
|
|
|
};
|
|
|
|
void getUser(const std::string &id) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Wt::Dbo::Session &m_session;
|
|
|
|
mutable Wt::Dbo::ptr<User> m_user;
|
|
|
|
};
|
|
|
|
#endif // __BLOGUSERDATABASE_H__
|