add code.
Some checks failed
Deploy / PullDocker (push) Successful in 5s
Deploy Docker Images / Docusaurus build and Server deploy (push) Successful in 17s
Deploy / Build (push) Failing after 9m47s

This commit is contained in:
luocai 2024-11-08 20:25:31 +08:00
parent 8c0128c4e7
commit 87a11914f8
2 changed files with 11 additions and 9 deletions

View File

@ -61,11 +61,7 @@ Wt::Auth::User BlogUserDatabase::findWithIdentity(const std::string &provider, c
if (provider == Wt::Auth::Identity::LoginName) {
if (!m_user || m_user->name != identity) m_user = m_session.find<User>().where("name = ?").bind(identity);
} else
m_user = m_session.find<User>()
.where("oauth_id = ?")
.bind(identity.toUTF8())
.where("oauth_provider = ?")
.bind(provider);
m_user = m_session.find<User>().where("oauth_id = ?").bind(identity.toUTF8()).where("oauth_provider = ?").bind(provider);
t.commit();
if (m_user)
@ -74,8 +70,7 @@ Wt::Auth::User BlogUserDatabase::findWithIdentity(const std::string &provider, c
return Wt::Auth::User();
}
void BlogUserDatabase::addIdentity(const Wt::Auth::User &user, const std::string &provider,
const Wt::WString &identity) {
void BlogUserDatabase::addIdentity(const Wt::Auth::User &user, const std::string &provider, const Wt::WString &identity) {
WithUser find(*this, user);
if (provider == Wt::Auth::Identity::LoginName)
@ -119,8 +114,14 @@ Wt::Auth::PasswordHash BlogUserDatabase::password(const Wt::Auth::User &user) co
return Wt::Auth::PasswordHash(m_user->passwordMethod, m_user->passwordSalt, m_user->password);
}
BlogUserDatabase::WithUser::WithUser(const BlogUserDatabase &self, const Wt::Auth::User &user)
: transaction(self.m_session) {
void BlogUserDatabase::setPassword(const Wt::Auth::User &user, const Wt::Auth::PasswordHash &password) {
WithUser find(*this, user);
m_user.modify()->password = password.value();
m_user.modify()->passwordMethod = password.function();
m_user.modify()->passwordSalt = password.salt();
}
BlogUserDatabase::WithUser::WithUser(const BlogUserDatabase &self, const Wt::Auth::User &user) : transaction(self.m_session) {
self.getUser(user.id());
if (!self.m_user) throw InvalidUser(user.id());

View File

@ -22,6 +22,7 @@ public:
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;
Wt::Auth::PasswordHash password(const Wt::Auth::User &user) const final;
void setPassword(const Wt::Auth::User &user, const Wt::Auth::PasswordHash &password) final;
protected:
struct WithUser {