Skip to content

Commit 99366ac

Browse files
authored
Merge pull request #147 from rambit-systems/push-tzwmrtottxzm
Org creation page, sendwrapper panics
2 parents 4d40f06 + bfeda93 commit 99366ac

File tree

15 files changed

+259
-196
lines changed

15 files changed

+259
-196
lines changed

Cargo.lock

Lines changed: 34 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ console_error_panic_hook = "0.1"
6262
wasm-bindgen = "=0.2.100"
6363

6464
[patch.crates-io]
65-
leptos = { git = 'https://github.com/johnbchron/leptos.git' }
66-
leptos_axum = { git = 'https://github.com/johnbchron/leptos.git' }
67-
leptos_meta = { git = 'https://github.com/johnbchron/leptos.git' }
68-
leptos_router = { git = 'https://github.com/johnbchron/leptos.git' }
65+
leptos = { git = 'https://github.com/leptos-rs/leptos.git' }
66+
leptos_axum = { git = 'https://github.com/leptos-rs/leptos.git' }
67+
leptos_meta = { git = 'https://github.com/leptos-rs/leptos.git' }
68+
leptos_router = { git = 'https://github.com/leptos-rs/leptos.git' }
6969

7070
[profile.wasm-release]
7171
codegen-units = 1

crates/auth-domain/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ impl AuthDomainService {
183183

184184
let user = User {
185185
id: user_id,
186-
orgs: (org.id, Vec::new()),
186+
personal_org: org.id,
187+
orgs: Vec::new(),
187188
name,
188189
email,
189190
auth,

crates/models/src/user.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ use crate::Org;
1515
pub struct User {
1616
/// The user's ID.
1717
pub id: RecordId<User>,
18-
/// The user's orgs, guaranteed to be at least one.
19-
pub orgs: (RecordId<Org>, Vec<RecordId<Org>>),
18+
/// The user's personal org.
19+
pub personal_org: RecordId<Org>,
20+
/// The user's named orgs.
21+
pub orgs: Vec<RecordId<Org>>,
2022
/// The user's name.
2123
pub name: HumanName,
2224
/// The user's email address.
@@ -42,12 +44,12 @@ impl User {
4244

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

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

@@ -131,8 +133,10 @@ impl Model for User {
131133
pub struct AuthUser {
132134
/// The user's ID.
133135
pub id: RecordId<User>,
134-
/// The user's orgs, guaranteed to be at least one.
135-
pub orgs: (RecordId<Org>, Vec<RecordId<Org>>),
136+
/// The user's personal org.
137+
pub personal_org: RecordId<Org>,
138+
/// The user's named orgs.
139+
pub orgs: Vec<RecordId<Org>>,
136140
/// The user's name.
137141
pub name: HumanName,
138142
/// The hash of the user's authentication secrets.
@@ -147,6 +151,7 @@ impl From<User> for AuthUser {
147151
user.auth_hash().to_be_bytes().to_vec().into_boxed_slice();
148152
Self {
149153
id: user.id,
154+
personal_org: user.personal_org,
150155
orgs: user.orgs,
151156
name: user.name,
152157
auth_hash_bytes,
@@ -158,12 +163,12 @@ impl From<User> for AuthUser {
158163
impl AuthUser {
159164
/// Returns an iterator of the user's orgs.
160165
pub fn iter_orgs(&self) -> impl Iterator<Item = RecordId<Org>> {
161-
once(self.orgs.0).chain(self.orgs.1.iter().copied())
166+
once(self.personal_org).chain(self.orgs.iter().copied())
162167
}
163168

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

169174
/// Returns the ID of the currently active org.

crates/prime-domain/src/migrate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ impl PrimeDomainService {
4242
.user_repo
4343
.create_model(User {
4444
id: user_id,
45-
orgs: (personal_org.id, vec![federation.id]),
45+
personal_org: personal_org.id,
46+
orgs: vec![federation.id],
4647
email: EmailAddress::try_new("jpicard@federation.gov")
4748
.unwrap(),
4849
name: HumanName::try_new("Jean-Luc Picard")
1.4 KB
Loading

0 commit comments

Comments
 (0)