Skip to content

Commit b565849

Browse files
committed
fixup remove authz_user -> user
1 parent 5fb0a84 commit b565849

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

editoast/src/authentication.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,13 @@ pub enum State {
8484
}
8585

8686
impl State {
87-
pub fn user(&self) -> Option<&editoast_models::User> {
87+
pub fn user(&self) -> Option<authz::User> {
8888
match self {
8989
State::Skip => None,
90-
State::Authenticated { user, .. } => Some(user),
90+
State::Authenticated { user, .. } => Some(authz::User(user.id)),
9191
}
9292
}
9393

94-
pub fn authz_user(&self) -> Option<authz::User> {
95-
self.user().map(|user| authz::User(user.id))
96-
}
97-
9894
pub fn roles(&self) -> &[Role] {
9995
static EMPTY_ROLES: [Role; 0] = [];
10096
match self {

editoast/src/views/authz.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub(in crate::views) async fn user_groups(
163163
}): State<AppState>,
164164
) -> Result<Json<Vec<Group>>> {
165165
let user = authn_state
166-
.authz_user()
166+
.user()
167167
.ok_or(AuthorizationError::Unauthenticated)?;
168168
let authorizer = authn_state.authorizer(regulator.openfga(), db_pool.get().await?);
169169
let user_groups = authz::v2::user_groups(user)
@@ -528,7 +528,7 @@ pub(in crate::views) async fn user_grants(
528528
Json(body): Json<HashMap<ResourceType, Vec<i64>>>,
529529
) -> Result<Json<HashMap<ResourceType, Vec<UserResourceGrant>>>> {
530530
let user = authn_state
531-
.authz_user()
531+
.user()
532532
.ok_or(AuthorizationError::Unauthenticated)?;
533533
let authorizer = authn_state.authorizer(regulator.openfga(), db_pool.get().await?);
534534
let mut response = HashMap::<_, Vec<UserResourceGrant>>::new();

0 commit comments

Comments
 (0)