WIP. Added User form

This commit is contained in:
emeric
2014-07-30 14:32:46 +02:00
parent b2bb2e0be1
commit 1f41f7f481
13 changed files with 695 additions and 39 deletions
+6
View File
@@ -103,6 +103,12 @@ Handler::getCurrentUser()
User::pointer
Handler::getUser(const Wt::Auth::User& authUser)
{
if (!authUser.isValid()) {
std::cerr << "Handler::getUser: invalid authUser" << std::endl;
return User::pointer();
}
Wt::Dbo::ptr<AuthInfo> authInfo = _users->find(authUser);
User::pointer user = authInfo->user();
+1 -1
View File
@@ -15,7 +15,7 @@ namespace Database {
typedef Wt::Auth::Dbo::UserDatabase<AuthInfo> UserDatabase;
// Session living class handling the database
// Session living class handling the database and the login
class Handler
{
public:
+5
View File
@@ -21,6 +21,11 @@ User::getAll(Wt::Dbo::Session& session)
return std::vector<pointer>(res.begin(), res.end());
}
User::pointer
User::getById(Wt::Dbo::Session& session, std::string id)
{
return session.find<User>().where("id = ?").bind( id );
}
} // namespace Database
+10
View File
@@ -12,15 +12,25 @@ typedef Wt::Auth::Dbo::AuthInfo<User> AuthInfo;
class User {
public:
static const std::size_t MaxNameLength = 15;
User();
typedef Wt::Dbo::ptr<User> pointer;
// accessors
static pointer getById(Wt::Dbo::Session& session, std::string id);
static std::vector<pointer> getAll(Wt::Dbo::Session& session);
// write
void setAdmin(bool admin) { _isAdmin = admin; }
void setMaxAudioBitrate(std::size_t bitrate) { _maxAudioBitrate = bitrate; }
void setMaxVideoBitrate(std::size_t bitrate) { _maxVideoBitrate = bitrate; }
// read
bool isAdmin() const {return _isAdmin;}
std::size_t getMaxAudioBitrate() const { return _maxAudioBitrate; }
std::size_t getMaxVideoBitrate() const { return _maxVideoBitrate; }
template<class Action>
void persist(Action& a)