Skip to content

Commit 5e8b12d

Browse files
committed
Refactor unauthenticated request handling in OIDC service
- Extracted logic for handling unauthenticated requests into a separate method `handle_unauthenticated_request`. - Updated the main request handling flow to utilize the new method for improved readability and maintainability.
1 parent 08c97f6 commit 5e8b12d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/webserver/oidc.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ impl<S> OidcService<S> {
173173
.url();
174174
auth_url.to_string()
175175
}
176+
177+
fn handle_unauthenticated_request(&self, request: ServiceRequest) -> LocalBoxFuture<Result<ServiceResponse<BoxBody>, Error>> {
178+
let auth_url = self.build_auth_url(&request);
179+
Box::pin(async move {
180+
Ok(request.into_response(build_redirect_response(auth_url)))
181+
})
182+
}
176183
}
177184

178185
type LocalBoxFuture<T> = Pin<Box<dyn Future<Output = T> + 'static>>;
@@ -196,12 +203,8 @@ where
196203
log::trace!("Found SQLPage auth cookie: {cookie}");
197204
}
198205
None => {
199-
log::trace!("No SQLPage auth cookie found, redirecting to login");
200-
let auth_url = self.build_auth_url(&request);
201-
202-
return Box::pin(async move {
203-
Ok(request.into_response(build_redirect_response(auth_url)))
204-
});
206+
log::trace!("No SQLPage auth cookie found");
207+
return self.handle_unauthenticated_request(request);
205208
}
206209
}
207210
let future = self.service.call(request);

0 commit comments

Comments
 (0)