Bläddra i källkod

Follow microrm changes.

Kestrel 11 månader sedan
förälder
incheckning
f8767cd2ee
5 ändrade filer med 6 tillägg och 27 borttagningar
  1. 1 7
      src/realm.rs
  2. 1 6
      src/server/oidc/authorize.rs
  3. 1 1
      src/server/oidc/token.rs
  4. 1 1
      src/server/session.rs
  5. 2 12
      src/server/um.rs

+ 1 - 7
src/realm.rs

@@ -119,13 +119,7 @@ impl RealmHelper {
         let roles = requested_roles
             .into_iter()
             .filter(|x| available_roles.contains(x))
-            .flat_map(|v| {
-                self.realm
-                    .roles
-                    .with(schema::RoleID::default(), v)
-                    .first()
-                    .get()
-            })
+            .flat_map(|v| self.realm.roles.with_id(v).first().get())
             .flatten()
             .map(|v| v.wrapped().shortname)
             .collect();

+ 1 - 6
src/server/oidc/authorize.rs

@@ -95,12 +95,7 @@ pub(super) fn do_authorize(
         return make_redirect();
     };
 
-    let Ok(Some(user)) = realm
-        .users
-        .with(schema::UserID::default(), user_id)
-        .first()
-        .get()
-    else {
+    let Ok(Some(user)) = realm.users.with_id(user_id).first().get() else {
         return Err(OIDCError(
             OIDCErrorType::ServerError,
             "Internal state error!".into(),

+ 1 - 1
src/server/oidc/token.rs

@@ -42,7 +42,7 @@ fn do_authorization_code<'l>(
 
     let user = realm
         .users
-        .with(schema::UserID::default(), code.user)
+        .with_id(code.user)
         .first()
         .get()?
         .ok_or(OIDCError(

+ 1 - 1
src/server/session.rs

@@ -318,7 +318,7 @@ async fn v1_login_post(mut req: Request) -> tide::Result<tide::Response> {
                 if let Some(user_id) = auth.pending_user {
                     let user = realm
                         .users
-                        .with(user_id, user_id)
+                        .with_id(user_id)
                         .first()
                         .get()?
                         .ok_or(UIDCError::Abort("session auth refers to nonexistent user"))?;

+ 2 - 12
src/server/um.rs

@@ -45,12 +45,7 @@ async fn um_index(req: Request) -> tide::Result<tide::Response> {
         }
     };
 
-    let user = realm
-        .users
-        .with(schema::UserID::default(), user_id)
-        .first()
-        .get()?
-        .unwrap();
+    let user = realm.users.with_id(user_id).first().get()?.unwrap();
 
     let template_data = generate_template_data(&realm, &user)?;
 
@@ -86,12 +81,7 @@ async fn um_update(mut req: Request) -> tide::Result<tide::Response> {
         }
     };
 
-    let user = realm
-        .users
-        .with(schema::UserID::default(), user_id)
-        .first()
-        .get()?
-        .unwrap();
+    let user = realm.users.with_id(user_id).first().get()?.unwrap();
 
     log::info!("processing update request...");