Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve admin invite #5403

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

stefan0xC
Copy link
Contributor

As pointed out by @Timshel the OrganizationId guard and especially the MembershipId guard is unhappy with the _ we use when inviting via the /admin panel.

By introducing a fake UUID "00000000-0000-0000-0000-000000000000" the guards will not fail and we can also check the claim and exit early.

BlackDex
BlackDex previously approved these changes Jan 16, 2025
Copy link
Collaborator

@BlackDex BlackDex left a comment

Choose a reason for hiding this comment

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

Seems good and logical the me. Not tested though.

@stefan0xC
Copy link
Contributor Author

stefan0xC commented Jan 16, 2025

Not sure if that is important but the mail with the confirmation will not be send.

// User was invited from /admin, so they are automatically confirmed
mail::send_invite_confirmed(&claims.email, &org_name).await?;

edit: refactored the logic a bit so the mail will be sent.

}

match User::find_by_mail(&claims.email, &mut conn).await {
Copy link
Contributor

@Timshel Timshel Jan 17, 2025

Choose a reason for hiding this comment

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

I think it would be better to retrieve the user from the Header guard instead and check that the correct user is making the call.

Made a PR in case you think it makes more sense to keep the change separate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, wow. I've never noticed. Yeah, sounds reasonable.

mut conn: DbConn,
) -> EmptyResult {
// The web-vault passes org_id and member_id in the URL, but we are just reading them from the JWT instead
let data: AcceptData = data.into_inner();
let claims = decode_invite(&data.token)?;

if !claims.email.eq(&headers.user.email) {
err!("Error accepting invitation", "Claim does not match user_id")
Copy link
Contributor

Choose a reason for hiding this comment

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

The notification title is : Unable to accept invitation, so I think the Error accepting invitation is a bit redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants