1use conrad_core::{Key, KeyTimestamp, KeyType, UserId};
2
3pub mod errors;
4pub mod id_tokens;
5pub mod password_tokens;
6
7pub struct Token {
8 value: String,
9 pub user_id: UserId,
10 pub expires_at: KeyTimestamp,
11}
12
13impl ToString for Token {
14 fn to_string(&self) -> String {
15 self.value.clone()
16 }
17}
18
19impl Token {
20 fn new(value: String, key: Key) -> Self {
21 if let KeyType::SingleUse { expires_in } = key.key_type {
22 Self {
23 value,
24 expires_at: expires_in,
25 user_id: key.user_id,
26 }
27 } else {
28 unreachable!()
29 }
30 }
31}