mirror of
https://github.com/matrix-construct/construct
synced 2024-09-26 18:38:52 +02:00
ircd:Ⓜ️:user: Move is_active() to adl'ed active().
This commit is contained in:
parent
1a1826bded
commit
ff96eb803d
4 changed files with 25 additions and 26 deletions
|
@ -18,6 +18,7 @@ namespace ircd::m
|
||||||
bool my(const user &);
|
bool my(const user &);
|
||||||
bool exists(const id::user &);
|
bool exists(const id::user &);
|
||||||
bool exists(const user &);
|
bool exists(const user &);
|
||||||
|
bool active(const user &);
|
||||||
bool is_oper(const user &);
|
bool is_oper(const user &);
|
||||||
|
|
||||||
user create(const id::user &, const json::members &args = {});
|
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;
|
bool is_password(const string_view &password) const;
|
||||||
event::id::buf password(const string_view &password);
|
event::id::buf password(const string_view &password);
|
||||||
|
|
||||||
bool is_active() const;
|
|
||||||
event::id::buf deactivate();
|
event::id::buf deactivate();
|
||||||
event::id::buf activate();
|
event::id::buf activate();
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,26 @@ ircd::m::is_oper(const user &user)
|
||||||
return m::membership(control_room_id, user, "join");
|
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
|
bool
|
||||||
ircd::m::exists(const user &user)
|
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::event::id::buf
|
||||||
ircd::m::user::password(const string_view &password)
|
ircd::m::user::password(const string_view &password)
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,7 +96,7 @@ post__login_password(client &client,
|
||||||
"Access denied."
|
"Access denied."
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!user.is_active())
|
if(!active(user))
|
||||||
throw m::FORBIDDEN
|
throw m::FORBIDDEN
|
||||||
{
|
{
|
||||||
"Access denied."
|
"Access denied."
|
||||||
|
|
|
@ -11173,7 +11173,7 @@ console_cmd__user__active(opt &out, const string_view &line)
|
||||||
};
|
};
|
||||||
|
|
||||||
out << user.user_id << " is "
|
out << user.user_id << " is "
|
||||||
<< (user.is_active()? "active" : "inactive")
|
<< (active(user)? "active" : "inactive")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -11195,7 +11195,7 @@ console_cmd__user__activate(opt &out, const string_view &line)
|
||||||
param.at(0)
|
param.at(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(user.is_active())
|
if(active(user))
|
||||||
{
|
{
|
||||||
out << user.user_id << " is already active" << std::endl;
|
out << user.user_id << " is already active" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -11226,7 +11226,7 @@ console_cmd__user__deactivate(opt &out, const string_view &line)
|
||||||
param.at(0)
|
param.at(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!user.is_active())
|
if(!active(user))
|
||||||
{
|
{
|
||||||
out << user.user_id << " is already inactive" << std::endl;
|
out << user.user_id << " is already inactive" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue