-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
base: main
Are you sure you want to change the base?
improve admin invite #5403
Conversation
a8e4a52
to
9a8cd55
Compare
There was a problem hiding this 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.
Not sure if that is important but the mail with the confirmation will not be send. vaultwarden/src/api/core/organizations.rs Lines 1206 to 1207 in 29f2b43
edit: refactored the logic a bit so the mail will be sent. |
} | ||
|
||
match User::find_by_mail(&claims.email, &mut conn).await { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/api/core/organizations.rs
Outdated
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") |
There was a problem hiding this comment.
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.
40d5e17
to
ec5679a
Compare
As pointed out by @Timshel the
OrganizationId
guard and especially theMembershipId
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.