surrealdb_expr/expr/user.rs
1use crate::expr::{Expr, Literal};
2use crate::val::Duration;
3
4#[derive(Debug, Hash, Clone, Eq, PartialEq)]
5// Durations representing the expiration of different elements of user
6// authentication In this context, the None variant represents that the element
7// does not expire
8pub struct UserDuration {
9 // Duration after which the token obtained after authenticating with user credentials expires
10 pub token: Expr,
11 // Duration after which the session authenticated with user credentials or token expires
12 pub session: Expr,
13}
14
15impl Default for UserDuration {
16 fn default() -> Self {
17 Self {
18 // By default, tokens expire after one hour
19 token: Expr::Literal(Literal::Duration(
20 Duration::from_hours(1).expect("1 hour should fit in a duration"),
21 )),
22 // By default, sessions do not expire
23 session: Expr::Literal(Literal::None),
24 }
25 }
26}