Older/WebApplication/model/User.h

38 lines
912 B
C
Raw Normal View History

2024-11-01 19:05:20 +08:00
#ifndef __USER_H__
#define __USER_H__
#include <Wt/Dbo/Types.h>
#include <Wt/Dbo/WtSqlTraits.h>
#include <Wt/WDateTime.h>
#include <Wt/WGlobal.h>
#include <Wt/WString.h>
class User {
public:
enum Role {
Visitor = 0,
Admin = 1,
};
User();
static Wt::Dbo::dbo_traits<User>::IdType stringToId(const std::string &s);
Wt::WString name;
Role role;
int failedLoginAttempts;
Wt::WDateTime lastLoginAttempt;
std::string oAuthId;
std::string oAuthProvider;
template <class Action>
void persist(Action &a) {
Wt::Dbo::field(a, name, "name");
Wt::Dbo::field(a, failedLoginAttempts, "failed_login_attempts");
Wt::Dbo::field(a, lastLoginAttempt, "last_login_attempt");
Wt::Dbo::field(a, oAuthId, "oauth_id");
Wt::Dbo::field(a, oAuthProvider, "oauth_provider");
}
};
DBO_EXTERN_TEMPLATES(User)
#endif // __USER_H__