Skip to content

Commit

Permalink
fix: fix hiding public forms
Browse files Browse the repository at this point in the history
  • Loading branch information
bodand committed May 29, 2024
1 parent 186e3fa commit 46ab23b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
7 changes: 5 additions & 2 deletions InForm.Server/Features/FillForms/Service/FillService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ private static void AddWithVisitor((FillDataDtoInjectorVisitor, FillElement) pai
var form = await dbContext.Forms.SingleOrDefaultAsync(x => x.IdGuid == formId);
if (form is null) throw new EntityNotFoundException();

form = await passwordHandler.Verify(form, password, dbContext);
if (form is null) throw new InvalidCredentialException();
if (password is not null)
{
form = await passwordHandler.Verify(form, password, dbContext);
if (form is null) throw new InvalidCredentialException();
}

var formElements = await dbContext.LoadAllElementsForFormWithData(form);
IVisitor<ElementResponse> visitor = new ToResponseDtoVisitor();
Expand Down
35 changes: 26 additions & 9 deletions InForm.Web/Features/Common/TextEntry.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,31 @@

<div class="@Class w-full">
<label for="@Id" class="text-zinc-700 dark:text-zinc-300">@Label</label>
<input id="@Id" type="@Type"
class="block w-full px-0 bg-transparent text-zinc-950
dark:text-zinc-100 border-0 border-b-2
focus:border-slate-950 focus:dark:border-slate-50 focus:ring-0
@CssClass"
@bind="CurrentValue"
autocomplete="off" />
@if (Multiline)
{
<textarea id="@Id"
class="block w-full px-0 bg-transparent text-zinc-950
dark:text-zinc-100 border-0 border-b-2
focus:border-slate-950 focus:dark:border-slate-50 focus:ring-0
@CssClass"
@bind="CurrentValue"
autocomplete="off">
</textarea>
}
else
{
<input id="@Id" type="@Type"
class="block w-full px-0 bg-transparent text-zinc-950
dark:text-zinc-100 border-0 border-b-2
focus:border-slate-950 focus:dark:border-slate-50 focus:ring-0
@CssClass"
@bind="CurrentValue"
autocomplete="off"/>
}

@if (ValidationFor is not null)
{
<ValidationMessage class="w-full" For="@ValidationFor" />
<ValidationMessage class="w-full" For="@ValidationFor"/>
}
</div>

Expand All @@ -33,10 +47,13 @@
[Parameter, EditorRequired]
public string Label { get; set; } = default!;

[Parameter]
public bool Multiline { get; set; } = false;

protected override bool TryParseValueFromString(string? value, out string result, out string validationErrorMessage)
{
result = value ?? string.Empty;
validationErrorMessage = null!; // actually nullable, Blazor doesn't mark it
validationErrorMessage = null!;// actually nullable, Blazor doesn't mark it
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<TextEntry Id="str_response"
Label="Response"
Multiline="CurrentValue!.Model.TextArea"
@bind-Value="CurrentValue!.Value"
ValidationFor="@(() => CurrentValue!.Value)"/>

Expand All @@ -10,4 +11,5 @@
out StringElementFillData result,
out string validationErrorMessage)
=> throw new NotImplementedException();
}
}

2 changes: 1 addition & 1 deletion InForm.Web/wwwroot/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
}
},
"InFormServer": {
"Url": "https://localhost:7017"
"Url": "https://localhost:44336/"
}
}

0 comments on commit 46ab23b

Please sign in to comment.