Skip to content

Commit dc3bdc9

Browse files
committed
fix(developer): serve github_id too
1 parent 944bdb0 commit dc3bdc9

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

src/database/repository/developers.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub async fn index(
2828
username,
2929
display_name,
3030
verified,
31-
admin
31+
admin,
32+
github_user_id as github_id
3233
FROM developers
3334
WHERE (
3435
($1 = '' OR username = $1)
@@ -98,7 +99,8 @@ pub async fn fetch_or_insert_github(
9899
username,
99100
display_name,
100101
verified,
101-
admin
102+
admin,
103+
github_user_id as github_id
102104
FROM developers
103105
WHERE github_user_id = $1",
104106
github_id
@@ -128,7 +130,8 @@ async fn insert_github(
128130
username,
129131
display_name,
130132
verified,
131-
admin",
133+
admin,
134+
github_user_id as github_id",
132135
username,
133136
github_id
134137
)
@@ -148,7 +151,8 @@ pub async fn get_one(id: i32, conn: &mut PgConnection) -> Result<Option<Develope
148151
username,
149152
display_name,
150153
verified,
151-
admin
154+
admin,
155+
github_user_id as github_id
152156
FROM developers
153157
WHERE id = $1",
154158
id
@@ -172,7 +176,8 @@ pub async fn get_one_by_username(
172176
username,
173177
display_name,
174178
verified,
175-
admin
179+
admin,
180+
github_user_id as github_id
176181
FROM developers
177182
WHERE username = $1",
178183
username
@@ -325,7 +330,8 @@ pub async fn get_owner_for_mod(
325330
dev.username,
326331
dev.display_name,
327332
dev.verified,
328-
dev.admin
333+
dev.admin,
334+
github_user_id as github_id
329335
FROM developers dev
330336
INNER JOIN mods_developers md ON md.developer_id = dev.id
331337
WHERE md.mod_id = $1
@@ -363,7 +369,8 @@ pub async fn update_status(
363369
username,
364370
display_name,
365371
verified,
366-
admin",
372+
admin,
373+
github_user_id as github_id",
367374
admin,
368375
verified,
369376
dev_id
@@ -391,7 +398,8 @@ pub async fn update_profile(
391398
username,
392399
display_name,
393400
verified,
394-
admin",
401+
admin,
402+
github_user_id as github_id",
395403
display_name,
396404
dev_id
397405
)
@@ -415,7 +423,8 @@ pub async fn find_by_refresh_token(
415423
d.username,
416424
d.display_name,
417425
d.admin,
418-
d.verified
426+
d.verified,
427+
d.github_user_id as github_id
419428
FROM developers d
420429
INNER JOIN refresh_tokens rt ON d.id = rt.developer_id
421430
WHERE rt.token = $1

src/endpoints/developers.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ pub async fn update_developer(
299299
auth.admin()?;
300300

301301
if payload.admin.is_none() && payload.verified.is_none() {
302-
return Err(ApiError::BadRequest("Specify at least one param to modify".into()))
302+
return Err(ApiError::BadRequest(
303+
"Specify at least one param to modify".into(),
304+
));
303305
}
304306

305307
let mut pool = data

src/extractors/auth.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ impl FromRequest for Auth {
7373
d.username,
7474
d.display_name,
7575
d.verified,
76-
d.admin
76+
d.admin,
77+
d.github_user_id as github_id
7778
FROM developers d
7879
INNER JOIN auth_tokens a ON d.id = a.developer_id
7980
WHERE a.token = $1",

src/types/models/developer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ pub struct Developer {
1515
pub display_name: String,
1616
pub verified: bool,
1717
pub admin: bool,
18+
pub github_id: i64
1819
}

0 commit comments

Comments
 (0)