Skip to content
Merged
68 changes: 34 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ console_error_panic_hook = "0.1"
wasm-bindgen = "=0.2.100"

[patch.crates-io]
leptos = { git = 'https://github.com/johnbchron/leptos.git' }
leptos_axum = { git = 'https://github.com/johnbchron/leptos.git' }
leptos_meta = { git = 'https://github.com/johnbchron/leptos.git' }
leptos_router = { git = 'https://github.com/johnbchron/leptos.git' }
leptos = { git = 'https://github.com/leptos-rs/leptos.git' }
leptos_axum = { git = 'https://github.com/leptos-rs/leptos.git' }
leptos_meta = { git = 'https://github.com/leptos-rs/leptos.git' }
leptos_router = { git = 'https://github.com/leptos-rs/leptos.git' }

[profile.wasm-release]
codegen-units = 1
Expand Down
3 changes: 2 additions & 1 deletion crates/auth-domain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ impl AuthDomainService {

let user = User {
id: user_id,
orgs: (org.id, Vec::new()),
personal_org: org.id,
orgs: Vec::new(),
name,
email,
auth,
Expand Down
21 changes: 13 additions & 8 deletions crates/models/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ use crate::Org;
pub struct User {
/// The user's ID.
pub id: RecordId<User>,
/// The user's orgs, guaranteed to be at least one.
pub orgs: (RecordId<Org>, Vec<RecordId<Org>>),
/// The user's personal org.
pub personal_org: RecordId<Org>,
/// The user's named orgs.
pub orgs: Vec<RecordId<Org>>,
/// The user's name.
pub name: HumanName,
/// The user's email address.
Expand All @@ -42,12 +44,12 @@ impl User {

/// Returns an iterator of the user's orgs.
pub fn iter_orgs(&self) -> impl Iterator<Item = RecordId<Org>> {
once(self.orgs.0).chain(self.orgs.1.iter().copied())
once(self.personal_org).chain(self.orgs.iter().copied())
}

/// Returns whether the user belongs to the given org.
pub fn belongs_to_org(&self, org: RecordId<Org>) -> bool {
self.orgs.0 == org || self.orgs.1.contains(&org)
self.personal_org == org || self.orgs.contains(&org)
}
}

Expand Down Expand Up @@ -131,8 +133,10 @@ impl Model for User {
pub struct AuthUser {
/// The user's ID.
pub id: RecordId<User>,
/// The user's orgs, guaranteed to be at least one.
pub orgs: (RecordId<Org>, Vec<RecordId<Org>>),
/// The user's personal org.
pub personal_org: RecordId<Org>,
/// The user's named orgs.
pub orgs: Vec<RecordId<Org>>,
/// The user's name.
pub name: HumanName,
/// The hash of the user's authentication secrets.
Expand All @@ -147,6 +151,7 @@ impl From<User> for AuthUser {
user.auth_hash().to_be_bytes().to_vec().into_boxed_slice();
Self {
id: user.id,
personal_org: user.personal_org,
orgs: user.orgs,
name: user.name,
auth_hash_bytes,
Expand All @@ -158,12 +163,12 @@ impl From<User> for AuthUser {
impl AuthUser {
/// Returns an iterator of the user's orgs.
pub fn iter_orgs(&self) -> impl Iterator<Item = RecordId<Org>> {
once(self.orgs.0).chain(self.orgs.1.iter().copied())
once(self.personal_org).chain(self.orgs.iter().copied())
}

/// Returns whether the user belongs to the given org.
pub fn belongs_to_org(&self, org: RecordId<Org>) -> bool {
self.orgs.0 == org || self.orgs.1.contains(&org)
self.personal_org == org || self.orgs.contains(&org)
}

/// Returns the ID of the currently active org.
Expand Down
3 changes: 2 additions & 1 deletion crates/prime-domain/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ impl PrimeDomainService {
.user_repo
.create_model(User {
id: user_id,
orgs: (personal_org.id, vec![federation.id]),
personal_org: personal_org.id,
orgs: vec![federation.id],
email: EmailAddress::try_new("jpicard@federation.gov")
.unwrap(),
name: HumanName::try_new("Jean-Luc Picard")
Expand Down
Binary file added crates/site-app/public/favicon-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading