fastauth_plugin_admin/model.rs
1//! The columns the admin plugin adds to `user` and `session`.
2
3use fastauth_core::plugin_prelude::*;
4
5/// The columns admin adds to `user`. None of them is client-settable; only admin endpoints
6/// and the server API change them. Apps read them with `session.user.plugin::<Admin, _>()`.
7#[derive(Fields, Clone, Debug, PartialEq, Eq)]
8#[fields(table = User)]
9pub struct AdminUser {
10 /// The user's roles, comma-separated (`"admin,support"`). Filled with the configured
11 /// default role right after the user is created; read it with [`Admin::roles_of`](crate::Admin::roles_of),
12 /// which falls back to the default role while it is empty.
13 pub role: Option<String>,
14 /// Whether the user is banned. Banned users can't sign in.
15 #[field(default = false)]
16 pub banned: bool,
17 /// Why the user is banned.
18 pub ban_reason: Option<String>,
19 /// When the ban lifts; `None` bans for good. Expired bans lift at the next sign-in.
20 pub ban_expires: Option<OffsetDateTime>,
21}
22
23/// The column admin adds to `session`: who is impersonating through it.
24#[derive(Fields, Clone, Debug, PartialEq, Eq)]
25#[fields(table = Session)]
26pub struct AdminSession {
27 /// The admin's user id, on sessions created by `/admin/impersonate-user`.
28 pub impersonated_by: Option<Id>,
29}