@@ -2,10 +2,9 @@ use chrono::NaiveDateTime;
2
2
use url:: Url ;
3
3
4
4
use crate :: github;
5
- use crate :: models:: token:: { CrateScope , EndpointScope } ;
6
5
use crate :: models:: {
7
- Category , Crate , CrateOwnerInvitation , CreatedApiToken , Dependency , DependencyKind , Keyword ,
8
- Owner , ReverseDependency , Team , TopVersions , User , Version , VersionDownload ,
6
+ ApiToken , Category , Crate , CrateOwnerInvitation , CreatedApiToken , Dependency , DependencyKind ,
7
+ Keyword , Owner , ReverseDependency , Team , TopVersions , User , Version , VersionDownload ,
9
8
VersionOwnerAction ,
10
9
} ;
11
10
use crate :: util:: rfc3339;
@@ -470,29 +469,17 @@ impl From<Team> for EncodableTeam {
470
469
/// the chance of token leaks.
471
470
#[ derive( Serialize , Debug ) ]
472
471
pub struct EncodableApiTokenWithToken {
473
- pub id : i32 ,
474
- pub name : String ,
475
- pub token : String ,
476
- #[ serde( with = "rfc3339" ) ]
477
- pub created_at : NaiveDateTime ,
478
- #[ serde( with = "rfc3339::option" ) ]
479
- pub last_used_at : Option < NaiveDateTime > ,
480
- /// `None` or a list of crate scope patterns (see RFC #2947)
481
- pub crate_scopes : Option < Vec < CrateScope > > ,
482
- /// A list of endpoint scopes or `None` for the `legacy` endpoint scope (see RFC #2947)
483
- pub endpoint_scopes : Option < Vec < EndpointScope > > ,
472
+ #[ serde( flatten) ]
473
+ pub token : ApiToken ,
474
+ #[ serde( rename = "token" ) ]
475
+ pub plaintext : String ,
484
476
}
485
477
486
478
impl From < CreatedApiToken > for EncodableApiTokenWithToken {
487
479
fn from ( token : CreatedApiToken ) -> Self {
488
480
EncodableApiTokenWithToken {
489
- id : token. model . id ,
490
- name : token. model . name ,
491
- token : token. plaintext ,
492
- created_at : token. model . created_at ,
493
- last_used_at : token. model . last_used_at ,
494
- crate_scopes : token. model . crate_scopes ,
495
- endpoint_scopes : token. model . endpoint_scopes ,
481
+ token : token. model ,
482
+ plaintext : token. plaintext ,
496
483
}
497
484
}
498
485
}
0 commit comments