26 #include "core/auth/User_odb.h" 42 return std::make_unique<PasswordChange>(ctx);
49 using query = odb::query<Auth::User>;
51 odb::transaction t(db->begin());
53 auto new_password = req.at(
"new_password").get<std::string>();
58 using namespace FlagSetOperator;
63 auto current_password = req.at(
"current_password").get<std::string>();
65 if (!user->verify_password(current_password))
75 user->password(new_password);
87 std::vector<ActionActionParam>
90 std::vector<ActionActionParam> perm;
static IUserEventPtr UserEvent(const DBPtr &database, Auth::UserPtr target_user, IAuditEntryPtr parent)
The base class for API method handler implementation.
This is the header file for a generated source file, GitSHA1.cpp.
PasswordChange(RequestContext ctx)
virtual json process_impl(const json &req) override
The API method implementation.
Audit::IAuditEntryPtr audit
The initial audit trail for the request.
static MethodHandlerUPtr create(RequestContext)
An attempt to change the password failed.
std::unique_ptr< MethodHandler > MethodHandlerUPtr
An exception that can be throw when the permission for a given operation is denied.
std::shared_ptr< IUserEvent > IUserEventPtr
std::shared_ptr< User > UserPtr
All modules that provides features to Leosac shall be in this namespace.
void clear_user_sessions(Auth::UserPtr user, APIPtr exception)
Deauthenticate all the connections of user, except the exception APISession.
Holds valuable pointer to provide context to a request.
std::shared_ptr< odb::database > DBPtr
std::vector< ActionActionParam > required_permission(const json &req) const override
Return a list of "Action" / "ActionParam" that must pass before the request is processed.