feat: add email to existing account, change password
This commit is contained in:
parent
77c3047b1e
commit
1cf2619393
13 changed files with 227 additions and 20 deletions
|
@ -183,7 +183,7 @@ public class EmailAuthController(
|
|||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpPost("add-email")]
|
||||
[HttpPost("add-account")]
|
||||
[Authorize("*")]
|
||||
public async Task<IActionResult> AddEmailAddressAsync([FromBody] AddEmailAddressRequest req)
|
||||
{
|
||||
|
@ -208,6 +208,9 @@ public class EmailAuthController(
|
|||
}
|
||||
else
|
||||
{
|
||||
ValidationUtils.Validate(
|
||||
[("password", ValidationUtils.ValidatePassword(req.Password))]
|
||||
);
|
||||
await authService.SetUserPasswordAsync(CurrentUser!, req.Password);
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
|
@ -232,7 +235,7 @@ public class EmailAuthController(
|
|||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpPost("add-email/callback")]
|
||||
[HttpPost("add-account/callback")]
|
||||
[Authorize("*")]
|
||||
public async Task<IActionResult> AddEmailCallbackAsync([FromBody] EmailCallbackRequest req)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ public class AccountCreationMailable(Config config, AccountCreationMailableView
|
|||
{
|
||||
To(view.To)
|
||||
.From(config.EmailAuth.From!)
|
||||
.Subject("Create an account")
|
||||
.View("~/Views/Mail/AccountCreation.cshtml", view)
|
||||
.Text(PlainText());
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public class AddEmailMailable(Config config, AddEmailMailableView view)
|
|||
{
|
||||
To(view.To)
|
||||
.From(config.EmailAuth.From!)
|
||||
.Subject("Confirm adding this email address to an existing account")
|
||||
.View("~/Views/Mail/AddEmail.cshtml", view)
|
||||
.Text(PlainText());
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<p>
|
||||
Please continue creating a new pronouns.cc account by using the following link:
|
||||
<br />
|
||||
<a href="@Model.BaseUrl/auth/callback/email/@Model.Code">Confirm your email address</a>
|
||||
<a href="@Model.BaseUrl/auth/callback/email/@Model.Code">@Model.BaseUrl/auth/callback/email/@Model.Code</a>
|
||||
<br />
|
||||
Note that this link will expire in one hour.
|
||||
</p>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<p>
|
||||
Hello @@@Model.Username, please confirm adding this email address to your account by using the following link:
|
||||
<br />
|
||||
<a href="@Model.BaseUrl/auth/callback/email/@Model.Code">Confirm your email address</a>
|
||||
<a href="@Model.BaseUrl/auth/callback/email/@Model.Code">@Model.BaseUrl/auth/callback/email/@Model.Code</a>
|
||||
<br />
|
||||
Note that this link will expire in one hour.
|
||||
</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue