Simplified the login throttler, corrected races on throttler access, recreate the auth cookie with the remaining duration
This commit is contained in:
@@ -213,6 +213,7 @@ Session::prepareTables()
|
||||
_session.execute("CREATE INDEX IF NOT EXISTS artist_sort_name_nocase_idx ON artist(sort_name COLLATE NOCASE)");
|
||||
_session.execute("CREATE INDEX IF NOT EXISTS artist_mbid_idx ON artist(mbid)");
|
||||
_session.execute("CREATE INDEX IF NOT EXISTS auth_token_user_idx ON auth_token(user_id)");
|
||||
_session.execute("CREATE INDEX IF NOT EXISTS auth_token_value_idx ON auth_token(value)");
|
||||
_session.execute("CREATE INDEX IF NOT EXISTS cluster_name_idx ON cluster(name)");
|
||||
_session.execute("CREATE INDEX IF NOT EXISTS cluster_cluster_type_idx ON cluster(cluster_type_id)");
|
||||
_session.execute("CREATE INDEX IF NOT EXISTS cluster_type_name_idx ON cluster_type(name)");
|
||||
|
||||
@@ -61,10 +61,12 @@ class AuthToken
|
||||
static pointer create(Session& session, const std::string& value, const Wt::WDateTime&expiry, Wt::Dbo::ptr<User> user);
|
||||
static void removeExpiredTokens(Session& session, Wt::WDateTime now);
|
||||
static pointer getByValue(Session& session, const std::string& value);
|
||||
static pointer getById(Session& session, IdType tokenId);
|
||||
|
||||
// Accessors
|
||||
Wt::Dbo::ptr<User> getUser() const { return _user; }
|
||||
const Wt::WDateTime& getExpiry() const { return _expiry; }
|
||||
Wt::Dbo::ptr<User> getUser() const { return _user; }
|
||||
const std::string& getValue() const { return _value; }
|
||||
|
||||
template<class Action>
|
||||
void persist(Action& a)
|
||||
@@ -121,6 +123,7 @@ class User : public Wt::Dbo::Dbo<User>
|
||||
const std::string& getLoginName() const { return _loginName; }
|
||||
PasswordHash getPasswordHash() const { return PasswordHash {_passwordSalt, _passwordHash}; }
|
||||
Wt::WDateTime getLastLogin() const { return _lastLogin; }
|
||||
std::size_t getAuthTokensCount() const { return _authTokens.size(); }
|
||||
|
||||
// write
|
||||
void setLastLogin(const Wt::WDateTime& dateTime) { _lastLogin = dateTime; }
|
||||
|
||||
Reference in New Issue
Block a user