Skip to content

Commit

Permalink
check for admin invite
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan0xC committed Jan 16, 2025
1 parent 29f2b43 commit 9a8cd55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/api/core/organizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,10 @@ async fn accept_invite(
Invitation::take(&claims.email, &mut conn).await;

if let (Some(member), Some(org)) = (&claims.member_id, &claims.org_id) {
if **member == "00000000-0000-0000-0000-000000000000" {
// exit early when the invitation was done via admin panel
return Ok(());
}
let Some(mut member) = Membership::find_by_uuid_and_org(member, org, &mut conn).await else {
err!("Error accepting the invitation")
};
Expand Down
20 changes: 10 additions & 10 deletions src/mail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,22 +264,22 @@ pub async fn send_invite(
org_name: &str,
invited_by_email: Option<String>,
) -> EmptyResult {
let claims = generate_invite_claims(
user.uuid.clone(),
user.email.clone(),
org_id.clone(),
member_id.clone(),
invited_by_email,
);
let invite_token = encode_jwt(&claims);
let org_id = match org_id {
Some(ref org_id) => org_id.as_ref(),
None => "_",
None => "00000000-0000-0000-0000-000000000000",
};
let member_id = match member_id {
Some(ref member_id) => member_id.as_ref(),
None => "_",
None => "00000000-0000-0000-0000-000000000000",
};
let claims = generate_invite_claims(
user.uuid.clone(),
user.email.clone(),
Some(org_id.to_string().into()),
Some(member_id.to_string().into()),
invited_by_email,
);
let invite_token = encode_jwt(&claims);
let mut query = url::Url::parse("https://query.builder").unwrap();
{
let mut query_params = query.query_pairs_mut();
Expand Down

0 comments on commit 9a8cd55

Please sign in to comment.