WIP. Added User form
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user