Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed May 22, 2024
1 parent 57b4571 commit 024113c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
7 changes: 6 additions & 1 deletion backend/LexBoxApi/GraphQL/UserMutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ EmailService emailService
public async Task<LexAuthUser> CreateGuestUserByAdmin(
LoggedInContext loggedInContext,
CreateGuestUserByAdminInput input,
LexBoxDbContext dbContext
LexBoxDbContext dbContext,
EmailService emailService
)
{
using var createGuestUserActivity = LexBoxActivitySource.Get().StartActivity("CreateGuestUser");
Expand Down Expand Up @@ -115,6 +116,10 @@ LexBoxDbContext dbContext
createGuestUserActivity?.AddTag("app.user.id", userEntity.Id);
dbContext.Users.Add(userEntity);
await dbContext.SaveChangesAsync();
if (!string.IsNullOrEmpty(input.Email))
{
await emailService.SendVerifyAddressEmail(userEntity);
}
return new LexAuthUser(userEntity);
}

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/lib/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type RegisterResponseErrors = {
/* eslint-disable @typescript-eslint/naming-convention */
TurnstileToken?: unknown,
Email?: unknown,
Required?: unknown,
Required?: unknown, // RequiredException is thrown if GQL input is invalid, e.g. missing both email *and* username for CreateUser
/* eslint-enable @typescript-eslint/naming-convention */
}
}
Expand Down Expand Up @@ -132,7 +132,6 @@ export async function createGuestUserByAdmin(password: string, passwordStrength:
gqlInput.username = email;
}
const gqlResponse = await _createGuestUserByAdmin(gqlInput);
// const registerResponse = { error?: { turnstile: boolean, accountExists: boolean }, user?: LexAuthUser };
if (gqlResponse.error?.byType('UniqueValueError')) {
return { error: { invalidInput: false, turnstile: false, accountExists: true }};
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/routes/(authenticated)/admin/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
{$t('admin_dashboard.create_user_modal.create_user')}
</span>
<span class="i-mdi-plus text-2xl" />
</button> </div>
</button>
</div>
</AdminTabs>
<div class="mt-4">
<FilterBar
Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/emailWorkflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ test('register via new-user invitation email', async ({ page }) => {
const newPage = await pagePromise;
const acceptPage = await new AcceptInvitationPage(newPage).waitFor();
await expect(newPage.getByLabel('Email')).toHaveValue(newEmail);
await acceptPage.fillForm(`Test user ${uuid}`, newEmail, defaultPassword);
await acceptPage.fillForm(`Test user ${uuid}`, defaultPassword);

await acceptPage.submit();
const userDashboardPage = await new UserDashboardPage(newPage).waitFor();
Expand Down
4 changes: 2 additions & 2 deletions frontend/tests/pages/acceptInvitationPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export class AcceptInvitationPage extends BasePage {
super(page, page.getByRole('heading', {name: 'Accept Invitation'}), `/acceptInvitation`);
}

async fillForm(name: string, email: string, password: string): Promise<void> {
async fillForm(name: string, password: string, email?: string): Promise<void> {
await this.page.getByLabel('Name').fill(name);
await this.page.getByLabel('Email').fill(email);
await this.page.getByLabel('Password').fill(password);
if (email) await this.page.getByLabel('Email').fill(email);
}

async submit(): Promise<void> {
Expand Down

0 comments on commit 024113c

Please sign in to comment.