|
6 | 6 | @using System.Text.Encodings.Web
|
7 | 7 | @using FairPlayCombined.Common.CustomAttributes
|
8 | 8 | @using FairPlayCombined.Common.ValidationAttributes
|
| 9 | +@using FairPlayCombined.Interfaces |
9 | 10 | @using FairPlayCombined.Models.Auth.ExternalLogin
|
10 | 11 | @using Microsoft.AspNetCore.Authentication
|
11 | 12 | @using Microsoft.AspNetCore.Identity
|
|
21 | 22 | @inject IdentityRedirectManager RedirectManager
|
22 | 23 | @inject ILogger<ExternalLogin> Logger
|
23 | 24 | @inject IStringLocalizer<ExternalLogin> localizer
|
| 25 | +@inject IUserValidationService userValidationService |
24 | 26 |
|
25 | 27 | <PageTitle>@localizer[RegisterTextKey]</PageTitle>
|
26 | 28 |
|
|
50 | 52 | <label for="name" class="@ThemeConfiguration.Labels.DefaultCss">@localizer[NameTextKey]</label>
|
51 | 53 | <InputText @bind-Value="Input.Name"
|
52 | 54 | class="@ThemeConfiguration.GenericControls.DefaultCss" autocomplete="name"
|
53 |
| - placeholder="@EnterYourNameText" /> |
| 55 | + placeholder="@EnterYourNameText" /> |
54 | 56 | <ValidationMessage For="() => Input.Name" />
|
55 | 57 | </div>
|
56 | 58 | <div class="@ThemeConfiguration.Divisions.DefaultCss">
|
|
62 | 64 | </div>
|
63 | 65 | <div class="@ThemeConfiguration.Divisions.DefaultCss">
|
64 | 66 | <label for="linkedinprofileurl"
|
65 |
| - class="@ThemeConfiguration.Labels.DefaultCss">@localizer[LinkedInProfileUrlTextKey]</label> |
| 67 | + class="@ThemeConfiguration.Labels.DefaultCss">@localizer[LinkedInProfileUrlTextKey]</label> |
66 | 68 | <InputText @bind-Value="Input.LinkedInProfileUrl"
|
67 |
| - class="@ThemeConfiguration.GenericControls.DefaultCss" |
68 |
| - autocomplete="linkedinprofileurl" |
69 |
| - placeholder="@EnterYourLinkedInProfileURL" /> |
| 69 | + class="@ThemeConfiguration.GenericControls.DefaultCss" |
| 70 | + autocomplete="linkedinprofileurl" |
| 71 | + placeholder="@EnterYourLinkedInProfileURL" /> |
70 | 72 | <ValidationMessage For="() => Input.LinkedInProfileUrl" />
|
71 | 73 | </div>
|
72 | 74 | <div class="@ThemeConfiguration.Divisions.DefaultCss">
|
73 | 75 | <label for="instagramprofileurl"
|
74 |
| - class="@ThemeConfiguration.Labels.DefaultCss">@localizer[InstagramProfileUrlTextKey]</label> |
| 76 | + class="@ThemeConfiguration.Labels.DefaultCss">@localizer[InstagramProfileUrlTextKey]</label> |
75 | 77 | <InputText @bind-Value="Input.InstagramProfileUrl"
|
76 |
| - class="@ThemeConfiguration.GenericControls.DefaultCss" |
77 |
| - autocomplete="instagramprofileurl" |
78 |
| - placeholder="@EnterYourInstagramProfileUrl" /> |
| 78 | + class="@ThemeConfiguration.GenericControls.DefaultCss" |
| 79 | + autocomplete="instagramprofileurl" |
| 80 | + placeholder="@EnterYourInstagramProfileUrl" /> |
79 | 81 | <ValidationMessage For="() => Input.InstagramProfileUrl" />
|
80 | 82 | </div>
|
81 | 83 | <div class="@ThemeConfiguration.Divisions.DefaultCss">
|
82 | 84 | <label for="xformerlytwitterurl"
|
83 |
| - class="@ThemeConfiguration.Labels.DefaultCss">@localizer[XFormerlyTwitterProfileUrlTextKey]</label> |
| 85 | + class="@ThemeConfiguration.Labels.DefaultCss">@localizer[XFormerlyTwitterProfileUrlTextKey]</label> |
84 | 86 | <InputText @bind-Value="Input.XformerlyTwitterUrl"
|
85 |
| - class="@ThemeConfiguration.GenericControls.DefaultCss" |
86 |
| - autocomplete="xformerlytwitterurl" |
87 |
| - placeholder="@EnterYourXFormerlyTwitterProfileUrl" /> |
| 87 | + class="@ThemeConfiguration.GenericControls.DefaultCss" |
| 88 | + autocomplete="xformerlytwitterurl" |
| 89 | + placeholder="@EnterYourXFormerlyTwitterProfileUrl" /> |
88 | 90 | <ValidationMessage For="() => Input.XformerlyTwitterUrl" />
|
89 | 91 | </div>
|
90 | 92 | <div class="@ThemeConfiguration.Divisions.DefaultCss">
|
91 | 93 | <label for="websiteurl"
|
92 |
| - class="@ThemeConfiguration.Labels.DefaultCss">@localizer[WebsiteUrlTextKey]</label> |
| 94 | + class="@ThemeConfiguration.Labels.DefaultCss">@localizer[WebsiteUrlTextKey]</label> |
93 | 95 | <InputText @bind-Value="Input.WebsiteUrl"
|
94 |
| - class="@ThemeConfiguration.GenericControls.DefaultCss" |
95 |
| - autocomplete="websiteurl" |
96 |
| - placeholder="@EnterYourWebsiteURL" /> |
| 96 | + class="@ThemeConfiguration.GenericControls.DefaultCss" |
| 97 | + autocomplete="websiteurl" |
| 98 | + placeholder="@EnterYourWebsiteURL" /> |
97 | 99 | <ValidationMessage For="() => Input.WebsiteUrl" />
|
98 | 100 | </div>
|
| 101 | + <div class="@ThemeConfiguration.Divisions.DefaultCss"> |
| 102 | + <label for="reasontocreateaccount" |
| 103 | + class="@ThemeConfiguration.Labels.DefaultCss">@localizer[ReasonToCreateAccountTextKey]</label> |
| 104 | + <InputTextArea @bind-Value="Input.ReasonToCreateAccount" |
| 105 | + class="@ThemeConfiguration.GenericControls.DefaultCss" |
| 106 | + autocomplete="reasontocreateaccount" |
| 107 | + placeholder="@EnterYourReasonToCreateAccount" /> |
| 108 | + <ValidationMessage For="() => Input.ReasonToCreateAccount" /> |
| 109 | + </div> |
99 | 110 | <button type="submit" class="w-100 btn btn-lg btn-primary">@localizer[RegisterTextKey]</button>
|
100 | 111 | </EditForm>
|
101 | 112 | </div>
|
|
192 | 203 |
|
193 | 204 | private async Task OnValidSubmitAsync()
|
194 | 205 | {
|
| 206 | + try |
| 207 | + { |
| 208 | + await userValidationService.ValidateUserDataAsync(name: Input.Name, lastName: Input.Lastname, email: Input.Email, |
| 209 | + reasonToCreateAccount: Input.ReasonToCreateAccount!, CancellationToken.None); |
| 210 | + } |
| 211 | + catch (Exception ex) |
| 212 | + { |
| 213 | + IdentityError identityError = new() |
| 214 | + { |
| 215 | + Code = "N/A", |
| 216 | + Description = ex.Message |
| 217 | + }; |
| 218 | + message = $"Error: {ex.Message}"; |
| 219 | + return; |
| 220 | + } |
| 221 | + |
195 | 222 | var emailStore = GetEmailStore();
|
196 | 223 | var user = CreateUser();
|
197 | 224 | user.Name = Input.Name;
|
|
212 | 239 | {
|
213 | 240 | user.WebsiteUrl = Input.WebsiteUrl;
|
214 | 241 | }
|
| 242 | + user.ReasonToCreateAccount = Input.ReasonToCreateAccount; |
215 | 243 | await UserStore.SetUserNameAsync(user, Input.Email, CancellationToken.None);
|
216 | 244 | await emailStore.SetEmailAsync(user, Input.Email, CancellationToken.None);
|
217 | 245 |
|
|
312 | 340 | [ResourceKey(defaultValue: "Please enter your Website URL")]
|
313 | 341 | public const string EnterYourWebsiteURLTextKey = "EnterYourWebsiteURLText";
|
314 | 342 | private string EnterYourWebsiteURL => localizer[EnterYourWebsiteURLTextKey];
|
| 343 | + [ResourceKey(defaultValue: "Reason to create account")] |
| 344 | + public const string ReasonToCreateAccountTextKey = "ReasonToCreateAccountText"; |
| 345 | + [ResourceKey("Enter your reason to create account")] |
| 346 | + public const string EnterYourReasonToCreateAccountTextKey = "EnterYourReasonToCreateAccountText"; |
| 347 | + private string EnterYourReasonToCreateAccount => localizer[EnterYourReasonToCreateAccountTextKey]; |
315 | 348 | [ResourceKey(defaultValue: "Error from external provider")]
|
316 | 349 | public const string ErrorFromExternalProviderTextKey = "ErrorFromExternalProviderText";
|
317 | 350 | [ResourceKey(defaultValue: "Error loading external login information")]
|
|
0 commit comments