Skip to content

Commit

Permalink
Do not use Consent.fromUserId to render [from|inviting]UserEmail email (
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Jun 7, 2024
1 parent b03e831 commit c0ad99b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions app/lib/account/consent_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ class ConsentBackend {
InvalidInputException.checkUlid(consentId, 'consentId');
final c = await _lookupAndCheck(consentId, user);
final action = _actions[c.kind]!;
final invitingUserEmail =
(await accountBackend.getEmailOfUserId(c.fromUserId!))!;
final fromAgent = c.fromAgent!;
late String invitingUserEmail;
if (looksLikeUserId(fromAgent)) {
invitingUserEmail = (await accountBackend.getEmailOfUserId(fromAgent))!;
} else {
invitingUserEmail = fromAgent;
}
return api.Consent(
titleText: action.renderInviteTitleText(invitingUserEmail, c.args!),
descriptionHtml: action.renderInviteHtml(
Expand Down Expand Up @@ -331,7 +336,6 @@ class _PackageUploaderAction extends ConsentAction {
final packageName = consent.args![0];
final createdBySiteAdmin = consent.createdBySiteAdmin ?? false;
final fromUserId = consent.fromUserId!;
final fromUserEmail = (await accountBackend.getEmailOfUserId(fromUserId))!;
final currentUser = await requireAuthenticatedWebUser();
if (currentUser.email?.toLowerCase() != consent.email?.toLowerCase()) {
throw NotAcceptableException(
Expand All @@ -340,7 +344,6 @@ class _PackageUploaderAction extends ConsentAction {

await packageBackend.confirmUploader(
fromUserId,
fromUserEmail,
packageName,
currentUser.user,
consentRequestCreatedBySiteAdmin: createdBySiteAdmin,
Expand Down
1 change: 0 additions & 1 deletion app/lib/package/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,6 @@ class PackageBackend {

Future<void> confirmUploader(
String fromUserId,
String fromUserEmail,
String packageName,
User uploader, {
required bool consentRequestCreatedBySiteAdmin,
Expand Down

0 comments on commit c0ad99b

Please sign in to comment.