locale
This commit is contained in:
parent
ed75f6f55c
commit
5351721d49
5 changed files with 66 additions and 42 deletions
|
|
@ -14,12 +14,9 @@ using Microsoft.AspNet.Http;
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
using Yavsc.Services;
|
using Yavsc.Services;
|
||||||
using Yavsc.ViewModels.Account;
|
using Yavsc.ViewModels.Account;
|
||||||
using Yavsc.Helpers;
|
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.Data.Entity;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Yavsc.Models.Messaging;
|
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -224,16 +221,19 @@ namespace Yavsc.Controllers
|
||||||
// Send an email with this link
|
// Send an email with this link
|
||||||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||||
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
|
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
|
||||||
var emailSent = await _emailSender.SendEmailAsync(_siteSettings, _smtpSettings, model.Email, "Confirm your account",
|
var emailSent = await _emailSender.SendEmailAsync(_siteSettings, _smtpSettings, model.Email, _localizer["ConfirmYourAccountTitle"],
|
||||||
"Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
|
string.Format(_localizer["ConfirmYourAccountBody"], _siteSettings.Title, callbackUrl, _siteSettings.Slogan, _siteSettings.Audience));
|
||||||
await _signInManager.SignInAsync(user, isPersistent: false);
|
await _signInManager.SignInAsync(user, isPersistent: false);
|
||||||
if (!emailSent) {
|
if (!emailSent)
|
||||||
|
{
|
||||||
_logger.LogWarning("User created with error sending email confirmation request");
|
_logger.LogWarning("User created with error sending email confirmation request");
|
||||||
this.NotifyWarning(
|
this.NotifyWarning(
|
||||||
"E-mail confirmation",
|
"E-mail confirmation",
|
||||||
_localizer["ErrorSendingEmailForConfirm"]
|
_localizer["ErrorSendingEmailForConfirm"]
|
||||||
);
|
);
|
||||||
} else this.NotifyInfo (
|
}
|
||||||
|
else
|
||||||
|
this.NotifyInfo(
|
||||||
"E-mail confirmation",
|
"E-mail confirmation",
|
||||||
_localizer["EmailSentForConfirm"]
|
_localizer["EmailSentForConfirm"]
|
||||||
);
|
);
|
||||||
|
|
@ -248,13 +248,20 @@ namespace Yavsc.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize, HttpPost, ValidateAntiForgeryToken]
|
[Authorize, HttpPost, ValidateAntiForgeryToken]
|
||||||
public async Task <IActionResult> SendEMailForConfirm () {
|
public async Task<IActionResult> SendEMailForConfirm()
|
||||||
|
{
|
||||||
var user = await _userManager.FindByIdAsync(User.GetUserId());
|
var user = await _userManager.FindByIdAsync(User.GetUserId());
|
||||||
|
ViewBag.EmailSent = SendEMailForConfirm(user);
|
||||||
|
return View("ConfirmEmailSent");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> SendEMailForConfirm(ApplicationUser user)
|
||||||
|
{
|
||||||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||||
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
|
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
|
||||||
await _emailSender.SendEmailAsync(_siteSettings, _smtpSettings, user.Email, "Confirm your account",
|
var res = await _emailSender.SendEmailAsync(_siteSettings, _smtpSettings, user.Email, "Confirm your account",
|
||||||
"Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
|
"Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
|
||||||
return View("ConfirmEmailSent");
|
return res;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// POST: /Account/LogOff
|
// POST: /Account/LogOff
|
||||||
|
|
@ -419,7 +426,8 @@ namespace Yavsc.Controllers
|
||||||
var user = await _userManager.FindByEmailAsync(model.LoginOrEmail);
|
var user = await _userManager.FindByEmailAsync(model.LoginOrEmail);
|
||||||
|
|
||||||
// Don't reveal that the user does not exist or is not confirmed
|
// Don't reveal that the user does not exist or is not confirmed
|
||||||
if (user == null) {
|
if (user == null)
|
||||||
|
{
|
||||||
user = await _userManager.FindByNameAsync(model.LoginOrEmail);
|
user = await _userManager.FindByNameAsync(model.LoginOrEmail);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
|
|
@ -430,7 +438,8 @@ namespace Yavsc.Controllers
|
||||||
// user != null
|
// user != null
|
||||||
// We want him to have a confirmed e-mail, and prevent this script
|
// We want him to have a confirmed e-mail, and prevent this script
|
||||||
// to be used to send e-mail to any arbitrary person
|
// to be used to send e-mail to any arbitrary person
|
||||||
if (!await _userManager.IsEmailConfirmedAsync(user)) {
|
if (!await _userManager.IsEmailConfirmedAsync(user))
|
||||||
|
{
|
||||||
_logger.LogWarning($"ForgotPassword: Email {model.LoginOrEmail} not confirmed");
|
_logger.LogWarning($"ForgotPassword: Email {model.LoginOrEmail} not confirmed");
|
||||||
return View("ForgotPasswordConfirmation");
|
return View("ForgotPasswordConfirmation");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -774,4 +774,13 @@ Valid caracters are: underscore '_', '-', 'a' - 'z', 'A' - 'Z', '0' - '9', th
|
||||||
<data name="EmailSentForConfirm">
|
<data name="EmailSentForConfirm">
|
||||||
<value>An email has been sent to confirm your addresse.</value>
|
<value>An email has been sent to confirm your addresse.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ConfirmYourAccountTitle"><value>Please, confirm your e-mail</value></data>
|
||||||
|
<data name="ConfirmYourAccountBody"><value>You successfully created your {0} account,
|
||||||
|
but your e-mail address is not yet confirmed.
|
||||||
|
Please, in order to validate it, follow this link <{1}>.
|
||||||
|
|
||||||
|
Thanks.
|
||||||
|
--
|
||||||
|
{0} - {2} <https://{3}></value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Binary file not shown.
|
|
@ -449,5 +449,11 @@
|
||||||
<data name="PasswordConfirm"><value>Confirmation du mot de passe</value></data>
|
<data name="PasswordConfirm"><value>Confirmation du mot de passe</value></data>
|
||||||
<data name="ErrorSendingEmailForConfirm"><value>L'envoi de de courrier pour confirmation de l'adresse e-mail a échoué.</value></data>
|
<data name="ErrorSendingEmailForConfirm"><value>L'envoi de de courrier pour confirmation de l'adresse e-mail a échoué.</value></data>
|
||||||
<data name="EmailSentForConfirm"><value>Un courrier a été envoyé pour confirmation de l'adresse e-mail .</value></data>
|
<data name="EmailSentForConfirm"><value>Un courrier a été envoyé pour confirmation de l'adresse e-mail .</value></data>
|
||||||
|
<data name="ConfirmYourAccountTitle"><value>S'il vous plait, confirmez votre addresse e-mail</value></data>
|
||||||
|
<data name="ConfirmYourAccountBody"><value>Vous avez créé avec succès votre compte {0},
|
||||||
|
mais votre adresse e-mail reste à confirmer.
|
||||||
|
Pour ce faire, suivez le lien suivant : <{1}>.
|
||||||
|
|
||||||
|
--
|
||||||
|
{0} - {2} <{3}></value></data>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue