0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-23 21:33:44 +02:00

ircd:Ⓜ️:user: Move is_active() to adl'ed active().

This commit is contained in:
Jason Volk 2020-05-02 12:27:49 -07:00
parent 1a1826bded
commit ff96eb803d
4 changed files with 25 additions and 26 deletions

View file

@ -18,6 +18,7 @@ namespace ircd::m
bool my(const user &);
bool exists(const id::user &);
bool exists(const user &);
bool active(const user &);
bool is_oper(const user &);
user create(const id::user &, const json::members &args = {});
@ -63,7 +64,6 @@ struct ircd::m::user
bool is_password(const string_view &password) const;
event::id::buf password(const string_view &password);
bool is_active() const;
event::id::buf deactivate();
event::id::buf activate();

View file

@ -25,6 +25,26 @@ ircd::m::is_oper(const user &user)
return m::membership(control_room_id, user, "join");
}
bool
ircd::m::active(const user &user)
{
const m::user::room user_room
{
user.user_id
};
const m::event::idx &event_idx
{
user_room.get(std::nothrow, "ircd.account", "active")
};
return m::query(std::nothrow, event_idx, "content", []
(const json::object &content)
{
return content.get<bool>("value", false);
});
}
bool
ircd::m::exists(const user &user)
{
@ -157,27 +177,6 @@ ircd::m::user::deactivate()
});
}
bool
ircd::m::user::is_active()
const
{
const m::user::room user_room
{
user_id
};
const m::event::idx &event_idx
{
user_room.get(std::nothrow, "ircd.account", "active")
};
return m::query(std::nothrow, event_idx, "content", []
(const json::object &content)
{
return content.get<bool>("value", false);
});
}
ircd::m::event::id::buf
ircd::m::user::password(const string_view &password)
{

View file

@ -96,7 +96,7 @@ post__login_password(client &client,
"Access denied."
};
if(!user.is_active())
if(!active(user))
throw m::FORBIDDEN
{
"Access denied."

View file

@ -11173,7 +11173,7 @@ console_cmd__user__active(opt &out, const string_view &line)
};
out << user.user_id << " is "
<< (user.is_active()? "active" : "inactive")
<< (active(user)? "active" : "inactive")
<< std::endl;
return true;
@ -11195,7 +11195,7 @@ console_cmd__user__activate(opt &out, const string_view &line)
param.at(0)
};
if(user.is_active())
if(active(user))
{
out << user.user_id << " is already active" << std::endl;
return true;
@ -11226,7 +11226,7 @@ console_cmd__user__deactivate(opt &out, const string_view &line)
param.at(0)
};
if(!user.is_active())
if(!active(user))
{
out << user.user_id << " is already inactive" << std::endl;
return true;