pub fn require_admin(session: &Arc<Mutex<AdminSession>>) -> boolExpand description
Checks if a command required admin privileges.
Uses the AdminSession built struct to determine if the current session is valid and has admin privileges.
If not, it prints an error message and returns false, stopping the command from executing.
The intention of this functionality is so that if someone was to have gotten unauthorised access to the actively running server and try to run a command, this safeguards against them running anything dangerous or destructive without first authenticating as an admin user. Which without the correct account information of the admin user, they are unable to do any serious harm.
§Arguments
session- A reference to the admin session, wrapped in Arc<Mutex<>> for thread-safe access.
§Returns
bool- Returns true if the session is valid and has admin privileges, false otherwise.
§Example
if !require_admin(session) {
return;
}