File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -86,15 +86,14 @@ pub async fn new(
86
86
parts: Parts,
87
87
Json(new): Json<NewApiTokenRequest>,
88
88
) -> AppResult<Json<Value>> {
89
+ if new.api_token.name.is_empty() {
90
+ return Err(bad_request("name must have a value"));
91
+ }
92
+
89
93
let conn = app.db_write().await?;
90
94
spawn_blocking(move || {
91
95
let conn: &mut AsyncConnectionWrapper<_> = &mut conn.into();
92
96
93
- let name = &new.api_token.name;
94
- if name.is_empty() {
95
- return Err(bad_request("name must have a value"));
96
- }
97
-
98
97
let auth = AuthCheck::default().check(&parts, conn)?;
99
98
if auth.api_token_id().is_some() {
100
99
return Err(bad_request(
@@ -141,15 +140,15 @@ pub async fn new(
141
140
let api_token = ApiToken::insert_with_scopes(
142
141
conn,
143
142
user.id,
144
- name,
143
+ &new.api_token. name,
145
144
crate_scopes,
146
145
endpoint_scopes,
147
146
new.api_token.expired_at,
148
147
)?;
149
148
150
149
if let Some(recipient) = recipient {
151
150
let email = NewTokenEmail {
152
- token_name: name,
151
+ token_name: &new.api_token. name,
153
152
user_name: &user.gh_login,
154
153
domain: &app.emails.domain,
155
154
};
You can’t perform that action at this time.
0 commit comments