Skip to content

feat: use discord_id from discord sso for role grant#6326

Open
IMB11 wants to merge 2 commits into
mainfrom
cal/discord-linking-flow-changes
Open

feat: use discord_id from discord sso for role grant#6326
IMB11 wants to merge 2 commits into
mainfrom
cal/discord-linking-flow-changes

Conversation

@IMB11
Copy link
Copy Markdown
Member

@IMB11 IMB11 commented Jun 7, 2026

No description provided.

@IMB11 IMB11 requested a review from aecsocket June 7, 2026 12:26
@modrinth-bot
Copy link
Copy Markdown
Member

Pull request changelog

App

Added

Changed

Deprecated

Removed

Fixed

Security

Website

Added

Changed

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

@modrinth-bot
Copy link
Copy Markdown
Member

modrinth-bot commented Jun 7, 2026

Comment on lines +1395 to +1404
#[utoipa::path(
post,
operation_id = "discordCommunityLink",
responses(
(status = 200, description = "Discord community bot handoff URL", body = DiscordCommunityLinkResponse),
(status = 400, description = "Discord provider not linked"),
(status = 401, description = "Unauthorized")
),
security(("bearer_auth" = ["SESSION_ACCESS"]))
)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[utoipa::path(
post,
operation_id = "discordCommunityLink",
responses(
(status = 200, description = "Discord community bot handoff URL", body = DiscordCommunityLinkResponse),
(status = 400, description = "Discord provider not linked"),
(status = 401, description = "Unauthorized")
),
security(("bearer_auth" = ["SESSION_ACCESS"]))
)]
#[utoipa::path(
operation_id = "discordCommunityLink",
responses(
(status = 200, description = "Discord community bot handoff URL", body = DiscordCommunityLinkResponse),
(status = 400, description = "Discord provider not linked"),
(status = 401, description = "Unauthorized")
),
security(("bearer_auth" = ["SESSION_ACCESS"]))
)]

Comment on lines +1430 to +1432
let Some(discord_id) = db_user.discord_id else {
return Err(ApiError::Request(eyre!("discord_not_linked")));
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let Some(discord_id) = db_user.discord_id else {
return Err(ApiError::Request(eyre!("discord_not_linked")));
};
let Some(discord_id) = db_user.discord_id else {
return Err(ApiError::Request(eyre!("discord account is not linked")));
};

unless you're matching on this exact string on the frontend to show some kind of unique message? in which case, make a new ApiError variant to make this explicit, or match on the new human-readable message

.await
.wrap_err("failed to begin Discord role email campaign transaction")?;

let lock_acquired = sqlx::query_scalar::<_, bool>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use query_scalar! macro

return Ok(());
}

let user_ids = sqlx::query_scalar::<_, i64>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use query_scalar! macro

Signed-off-by: Calum H. <calum@modrinth.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants