@@ -25,7 +25,7 @@ use shuttle_backends::metrics::{Metrics, TraceLayer};
2525use shuttle_backends:: project_name:: ProjectName ;
2626use shuttle_backends:: request_span;
2727use shuttle_backends:: ClaimExt ;
28- use shuttle_common:: claims:: { Scope , EXP_MINUTES } ;
28+ use shuttle_common:: claims:: { Claim , Scope , EXP_MINUTES } ;
2929use shuttle_common:: models:: error:: ErrorKind ;
3030use shuttle_common:: models:: service;
3131use shuttle_common:: models:: { admin:: ProjectResponse , project, stats} ;
@@ -47,7 +47,7 @@ use x509_parser::time::ASN1Time;
4747
4848use crate :: acme:: { AccountWrapper , AcmeClient , CustomDomain } ;
4949use crate :: api:: tracing:: project_name_tracing_layer;
50- use crate :: auth:: { ScopedUser , User } ;
50+ use crate :: auth:: ScopedUser ;
5151use crate :: service:: { ContainerSettings , GatewayService } ;
5252use crate :: task:: { self , BoxedTask } ;
5353use crate :: tls:: { GatewayCertResolver , RENEWAL_VALIDITY_THRESHOLD_IN_DAYS } ;
@@ -131,12 +131,12 @@ async fn check_project_name(
131131}
132132async fn get_projects_list (
133133 State ( RouterState { service, .. } ) : State < RouterState > ,
134- User { id , .. } : User ,
134+ Claim { sub , .. } : Claim ,
135135) -> Result < AxumJson < Vec < project:: Response > > , Error > {
136136 let mut projects = vec ! [ ] ;
137137 for p in service
138138 . permit_client
139- . get_user_projects ( & id )
139+ . get_user_projects ( & sub )
140140 . await
141141 . map_err ( |_| Error :: from ( ErrorKind :: Internal ) ) ?
142142 {
@@ -163,7 +163,7 @@ async fn create_project(
163163 State ( RouterState {
164164 service, sender, ..
165165 } ) : State < RouterState > ,
166- User { id , claim, .. } : User ,
166+ claim : Claim ,
167167 CustomErrorPath ( project_name) : CustomErrorPath < ProjectName > ,
168168 AxumJson ( config) : AxumJson < project:: Config > ,
169169) -> Result < AxumJson < project:: Response > , Error > {
@@ -172,7 +172,7 @@ async fn create_project(
172172 // Check that the user is within their project limits.
173173 let can_create_project = claim. can_create_project (
174174 service
175- . get_project_count ( & id )
175+ . get_project_count ( & claim . sub )
176176 . await ?
177177 . saturating_sub ( is_cch_project as u32 ) ,
178178 ) ;
@@ -184,7 +184,7 @@ async fn create_project(
184184 let project = service
185185 . create_project (
186186 project_name. clone ( ) ,
187- & id ,
187+ & claim . sub ,
188188 claim. is_admin ( ) ,
189189 can_create_project,
190190 if is_cch_project {
@@ -398,7 +398,7 @@ async fn override_create_service(
398398 scoped_user : ScopedUser ,
399399 req : Request < Body > ,
400400) -> Result < Response < Body > , Error > {
401- let user_id = scoped_user. user . id . clone ( ) ;
401+ let user_id = scoped_user. claim . sub . clone ( ) ;
402402 let posthog_client = state. posthog_client . clone ( ) ;
403403 tokio:: spawn ( async move {
404404 let event = async_posthog:: Event :: new ( "shuttle_api_start_deployment" , & user_id) ;
@@ -460,9 +460,9 @@ async fn route_project(
460460 let project_name = scoped_user. scope ;
461461 let is_cch_project = project_name. is_cch_project ( ) ;
462462
463- if !scoped_user. user . claim . is_admin ( ) {
463+ if !scoped_user. claim . is_admin ( ) {
464464 service
465- . has_capacity ( is_cch_project, & scoped_user. user . claim . tier )
465+ . has_capacity ( is_cch_project, & scoped_user. claim . tier )
466466 . await ?;
467467 }
468468
@@ -471,7 +471,7 @@ async fn route_project(
471471 . await ?
472472 . 0 ;
473473 service
474- . route ( & project. state , & project_name, & scoped_user. user . id , req)
474+ . route ( & project. state , & project_name, & scoped_user. claim . sub , req)
475475 . await
476476}
477477
0 commit comments