Skip to content

Commit 9a99f3b

Browse files
committed
auth: Remove obsolete async_ prefixes from fns
We don't use blocking check implementations anymore, so we remove these temporary prefixes.
1 parent ba761e6 commit 9a99f3b

File tree

10 files changed

+28
-28
lines changed

10 files changed

+28
-28
lines changed

src/auth.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ impl AuthCheck {
5757
}
5858
}
5959

60-
#[instrument(name = "auth.async_check", skip_all)]
61-
pub async fn async_check(
60+
#[instrument(name = "auth.check", skip_all)]
61+
pub async fn check(
6262
&self,
6363
parts: &Parts,
6464
conn: &mut AsyncPgConnection,
6565
) -> AppResult<Authentication> {
66-
let auth = async_authenticate(parts, conn).await?;
66+
let auth = authenticate(parts, conn).await?;
6767

6868
if let Some(token) = auth.api_token() {
6969
if !self.allow_token {
@@ -172,7 +172,7 @@ impl Authentication {
172172
}
173173

174174
#[instrument(skip_all)]
175-
async fn async_authenticate_via_cookie(
175+
async fn authenticate_via_cookie(
176176
parts: &Parts,
177177
conn: &mut AsyncPgConnection,
178178
) -> AppResult<Option<CookieAuthentication>> {
@@ -198,7 +198,7 @@ async fn async_authenticate_via_cookie(
198198
}
199199

200200
#[instrument(skip_all)]
201-
async fn async_authenticate_via_token(
201+
async fn authenticate_via_token(
202202
parts: &Parts,
203203
conn: &mut AsyncPgConnection,
204204
) -> AppResult<Option<TokenAuthentication>> {
@@ -237,19 +237,19 @@ async fn async_authenticate_via_token(
237237
}
238238

239239
#[instrument(skip_all)]
240-
async fn async_authenticate(
240+
async fn authenticate(
241241
parts: &Parts,
242242
conn: &mut AsyncPgConnection,
243243
) -> AppResult<Authentication> {
244244
controllers::util::verify_origin(parts)?;
245245

246-
match async_authenticate_via_cookie(parts, conn).await {
246+
match authenticate_via_cookie(parts, conn).await {
247247
Ok(None) => {}
248248
Ok(Some(auth)) => return Ok(Authentication::Cookie(auth)),
249249
Err(err) => return Err(err),
250250
}
251251

252-
match async_authenticate_via_token(parts, conn).await {
252+
match authenticate_via_token(parts, conn).await {
253253
Ok(None) => {}
254254
Ok(Some(auth)) => return Ok(Authentication::Token(auth)),
255255
Err(err) => return Err(err),

src/controllers/crate_owner_invitation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use tokio::runtime::Handle;
2929
pub async fn list(app: AppState, req: Parts) -> AppResult<Json<Value>> {
3030
let mut conn = app.db_read().await?;
3131
let auth = AuthCheck::only_cookie()
32-
.async_check(&req, &mut conn)
32+
.check(&req, &mut conn)
3333
.await?;
3434
spawn_blocking(move || {
3535
let conn: &mut AsyncConnectionWrapper<_> = &mut conn.into();
@@ -73,7 +73,7 @@ pub async fn list(app: AppState, req: Parts) -> AppResult<Json<Value>> {
7373
pub async fn private_list(app: AppState, req: Parts) -> AppResult<Json<PrivateListResponse>> {
7474
let mut conn = app.db_read().await?;
7575
let auth = AuthCheck::only_cookie()
76-
.async_check(&req, &mut conn)
76+
.check(&req, &mut conn)
7777
.await?;
7878
spawn_blocking(move || {
7979
let conn: &mut AsyncConnectionWrapper<_> = &mut conn.into();
@@ -288,7 +288,7 @@ pub async fn handle_invite(state: AppState, req: BytesRequest) -> AppResult<Json
288288
let crate_invite = crate_invite.crate_owner_invite;
289289

290290
let mut conn = state.db_write().await?;
291-
let auth = AuthCheck::default().async_check(&parts, &mut conn).await?;
291+
let auth = AuthCheck::default().check(&parts, &mut conn).await?;
292292
spawn_blocking(move || {
293293
let conn: &mut AsyncConnectionWrapper<_> = &mut conn.into();
294294

src/controllers/krate/follow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub async fn follow(
3636
) -> AppResult<Response> {
3737
let mut conn = app.db_write().await?;
3838
let user_id = AuthCheck::default()
39-
.async_check(&req, &mut conn)
39+
.check(&req, &mut conn)
4040
.await?
4141
.user_id();
4242
spawn_blocking(move || {
@@ -63,7 +63,7 @@ pub async fn unfollow(
6363
) -> AppResult<Response> {
6464
let mut conn = app.db_write().await?;
6565
let user_id = AuthCheck::default()
66-
.async_check(&req, &mut conn)
66+
.check(&req, &mut conn)
6767
.await?
6868
.user_id();
6969
spawn_blocking(move || {
@@ -87,7 +87,7 @@ pub async fn following(
8787
) -> AppResult<Json<Value>> {
8888
let mut conn = app.db_read_prefer_primary().await?;
8989
let user_id = AuthCheck::only_cookie()
90-
.async_check(&req, &mut conn)
90+
.check(&req, &mut conn)
9191
.await?
9292
.user_id();
9393
spawn_blocking(move || {

src/controllers/krate/owners.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ async fn modify_owners(
134134
let auth = AuthCheck::default()
135135
.with_endpoint_scope(EndpointScope::ChangeOwners)
136136
.for_crate(&crate_name)
137-
.async_check(&parts, &mut conn)
137+
.check(&parts, &mut conn)
138138
.await?;
139139
spawn_blocking(move || {
140140
use diesel::RunQueryDsl;

src/controllers/krate/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
102102
let auth = AuthCheck::default()
103103
.with_endpoint_scope(endpoint_scope)
104104
.for_crate(&metadata.name)
105-
.async_check(&req, &mut conn)
105+
.check(&req, &mut conn)
106106
.await?;
107107
(existing_crate, auth)
108108
};

src/controllers/krate/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl<'a> FilterParams<'a> {
310310
}
311311

312312
let user_id = Handle::current()
313-
.block_on(AuthCheck::default().async_check(req, conn))?
313+
.block_on(AuthCheck::default().check(req, conn))?
314314
.user_id();
315315

316316
// This should not fail, because of the `get()` check above

src/controllers/token.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub async fn list(
4343
) -> AppResult<Json<Value>> {
4444
let mut conn = app.db_read_prefer_primary().await?;
4545
let auth = AuthCheck::only_cookie()
46-
.async_check(&req, &mut conn)
46+
.check(&req, &mut conn)
4747
.await?;
4848
spawn_blocking(move || {
4949
use diesel::RunQueryDsl;
@@ -95,7 +95,7 @@ pub async fn new(
9595
}
9696

9797
let mut conn = app.db_write().await?;
98-
let auth = AuthCheck::default().async_check(&parts, &mut conn).await?;
98+
let auth = AuthCheck::default().check(&parts, &mut conn).await?;
9999
spawn_blocking(move || {
100100
use diesel::RunQueryDsl;
101101

@@ -178,7 +178,7 @@ pub async fn new(
178178
/// Handles the `GET /me/tokens/:id` route.
179179
pub async fn show(app: AppState, Path(id): Path<i32>, req: Parts) -> AppResult<Json<Value>> {
180180
let mut conn = app.db_write().await?;
181-
let auth = AuthCheck::default().async_check(&req, &mut conn).await?;
181+
let auth = AuthCheck::default().check(&req, &mut conn).await?;
182182
spawn_blocking(move || {
183183
use diesel::RunQueryDsl;
184184

@@ -198,7 +198,7 @@ pub async fn show(app: AppState, Path(id): Path<i32>, req: Parts) -> AppResult<J
198198
/// Handles the `DELETE /me/tokens/:id` route.
199199
pub async fn revoke(app: AppState, Path(id): Path<i32>, req: Parts) -> AppResult<Json<Value>> {
200200
let mut conn = app.db_write().await?;
201-
let auth = AuthCheck::default().async_check(&req, &mut conn).await?;
201+
let auth = AuthCheck::default().check(&req, &mut conn).await?;
202202
spawn_blocking(move || {
203203
use diesel::RunQueryDsl;
204204

@@ -217,7 +217,7 @@ pub async fn revoke(app: AppState, Path(id): Path<i32>, req: Parts) -> AppResult
217217
/// Handles the `DELETE /tokens/current` route.
218218
pub async fn revoke_current(app: AppState, req: Parts) -> AppResult<Response> {
219219
let mut conn = app.db_write().await?;
220-
let auth = AuthCheck::default().async_check(&req, &mut conn).await?;
220+
let auth = AuthCheck::default().check(&req, &mut conn).await?;
221221
spawn_blocking(move || {
222222
use diesel::RunQueryDsl;
223223

src/controllers/user/me.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::views::{EncodableMe, EncodablePrivateUser, EncodableVersion, OwnedCra
2323
pub async fn me(app: AppState, req: Parts) -> AppResult<Json<EncodableMe>> {
2424
let mut conn = app.db_read_prefer_primary().await?;
2525
let user_id = AuthCheck::only_cookie()
26-
.async_check(&req, &mut conn)
26+
.check(&req, &mut conn)
2727
.await?
2828
.user_id();
2929
spawn_blocking(move || {
@@ -71,7 +71,7 @@ pub async fn me(app: AppState, req: Parts) -> AppResult<Json<EncodableMe>> {
7171
pub async fn updates(app: AppState, req: Parts) -> AppResult<Json<Value>> {
7272
let mut conn = app.db_read_prefer_primary().await?;
7373
let auth = AuthCheck::only_cookie()
74-
.async_check(&req, &mut conn)
74+
.check(&req, &mut conn)
7575
.await?;
7676
spawn_blocking(move || {
7777
let conn: &mut AsyncConnectionWrapper<_> = &mut conn.into();
@@ -151,7 +151,7 @@ pub async fn update_email_notifications(app: AppState, req: BytesRequest) -> App
151151

152152
let mut conn = app.db_write().await?;
153153
let user_id = AuthCheck::default()
154-
.async_check(&parts, &mut conn)
154+
.check(&parts, &mut conn)
155155
.await?
156156
.user_id();
157157
spawn_blocking(move || {

src/controllers/user/update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub async fn update_user(
3434
Json(user_update): Json<UserUpdate>,
3535
) -> AppResult<Response> {
3636
let mut conn = state.db_write().await?;
37-
let auth = AuthCheck::default().async_check(&req, &mut conn).await?;
37+
let auth = AuthCheck::default().check(&req, &mut conn).await?;
3838
spawn_blocking(move || {
3939
use diesel::RunQueryDsl;
4040

@@ -121,7 +121,7 @@ pub async fn regenerate_token_and_send(
121121
req: Parts,
122122
) -> AppResult<Response> {
123123
let mut conn = state.db_write().await?;
124-
let auth = AuthCheck::default().async_check(&req, &mut conn).await?;
124+
let auth = AuthCheck::default().check(&req, &mut conn).await?;
125125
spawn_blocking(move || {
126126
use diesel::RunQueryDsl;
127127

src/controllers/version/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub async fn authenticate(
176176
AuthCheck::default()
177177
.with_endpoint_scope(EndpointScope::Yank)
178178
.for_crate(name)
179-
.async_check(req, conn)
179+
.check(req, conn)
180180
.await
181181
}
182182

0 commit comments

Comments
 (0)