| 1 | use super::{Email, OrgId, PasswordHash, UserId}; |
| 2 | |
| 3 | /// An account that can authenticate. |
| 4 | /// |
| 5 | /// A user's identity in URLs comes from their personal organisation, not from a |
| 6 | /// separate username — see `personal_org_id`. |
| 7 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 8 | pub struct User { |
| 9 | pub id: UserId, |
| 10 | pub email: Email, |
| 11 | pub password_hash: PasswordHash, |
| 12 | /// The organisation created alongside this user, whose name is their public handle. |
| 13 | pub personal_org_id: OrgId, |
| 14 | } |
| 15 | |
| 16 | impl User { |
| 17 | pub fn new( |
| 18 | id: UserId, |
| 19 | email: Email, |
| 20 | password_hash: PasswordHash, |
| 21 | personal_org_id: OrgId, |
| 22 | ) -> Self { |
| 23 | Self { |
| 24 | id, |
| 25 | email, |
| 26 | password_hash, |
| 27 | personal_org_id, |
| 28 | } |
| 29 | } |
| 30 | } |