fix: fixed login problems, email now cannot be changed if the mail is already in use when changing emails

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-06-12 21:22:44 +02:00
parent ce201207d4
commit 7f5a282058
5 changed files with 12 additions and 12 deletions

View file

@ -13,7 +13,7 @@
</RadzenFormField> </RadzenFormField>
<br/> <br/>
<br/> <br/>
<RadzenButton Click=@reset Text="reset" ButtonStyle="ButtonStyle.Secondary" ButtonType="ButtonType.Submit"/> <RadzenButton Click=@reset Text="reset" ButtonStyle="ButtonStyle.Secondary"/>
<br/> <br/>
</form> </form>
@if (msg != null) @if (msg != null)

View file

@ -18,7 +18,7 @@
</RadzenFormField> </RadzenFormField>
<br/> <br/>
<br/> <br/>
<RadzenButton Click=@login Text="login" ButtonStyle="ButtonStyle.Secondary" ButtonType="ButtonType.Submit"/> <RadzenButton Click=@login Text="login" ButtonStyle="ButtonStyle.Secondary"/>
<br/> <br/>
</form> </form>
</div> </div>

View file

@ -22,7 +22,7 @@
<RadzenLabel Text="I am atleast 18 Years old." Component="is_18"/> <RadzenLabel Text="I am atleast 18 Years old." Component="is_18"/>
<br/> <br/>
<br/> <br/>
<RadzenButton Click=@login Text="register" ButtonStyle="ButtonStyle.Secondary" ButtonType="ButtonType.Submit"/> <RadzenButton Click=@login Text="register" ButtonStyle="ButtonStyle.Secondary"/>
</form> </form>
<br/> <br/>
<br/> <br/>

View file

@ -10,7 +10,7 @@
</RadzenFormField> </RadzenFormField>
<br/> <br/>
<br/> <br/>
<RadzenButton Click=@resetPassword Text="Send reset email" ButtonStyle="ButtonStyle.Secondary" ButtonType="ButtonType.Submit"/> <RadzenButton Click=@resetPassword Text="Send reset email" ButtonStyle="ButtonStyle.Secondary"/>
<br/> <br/>
</form> </form>
@if (msg != null) @if (msg != null)

View file

@ -10,21 +10,15 @@
<Authorized> <Authorized>
<h3>YOUR ACCOUNT</h3> <h3>YOUR ACCOUNT</h3>
<br/> <br/>
<span>UserId: @userid</span> <span>Email: @userid</span>
<br/> <br/>
@if (u != null)
{
<span>Current email: @u.Email</span>
<br/>
}
<span>Email: </span>
<form> <form>
<RadzenFormField Text="Enter new email address" Variant="Variant.Outlined"> <RadzenFormField Text="Enter new email address" Variant="Variant.Outlined">
<RadzenTextBox @bind-Value="@newMail"/> <RadzenTextBox @bind-Value="@newMail"/>
</RadzenFormField> </RadzenFormField>
<br/> <br/>
<br/> <br/>
<RadzenButton Click=@changeEmail Text="Set Email" ButtonStyle="ButtonStyle.Secondary" ButtonType="ButtonType.Submit"/> <RadzenButton Click=@changeEmail Text="Set Email" ButtonStyle="ButtonStyle.Secondary"/>
<br/> <br/>
</form> </form>
@if (msg != null) @if (msg != null)
@ -82,6 +76,12 @@
msg = "The new email is not valid."; msg = "The new email is not valid.";
return; return;
} }
UserData u2 = await UsersRepository.getUserByEmailRawAsync(newMail);
if (u2 != null)
{
msg = "This email is already in use.";
return;
}
foundusr.Email = newMail; foundusr.Email = newMail;
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(); foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
foundusr.ConfirmedEmail = false; foundusr.ConfirmedEmail = false;