more friendly

This commit is contained in:
2017-09-24 23:42:41 +02:00
parent 68c8ff2a58
commit 109aa1bc55
11 changed files with 763 additions and 264 deletions

View File

@ -18,9 +18,12 @@ using Yavsc.Helpers;
using Microsoft.Extensions.Localization;
using Microsoft.Data.Entity;
using Newtonsoft.Json;
using System.Collections.Generic;
using Yavsc.Models.Messaging;
namespace Yavsc.Controllers
{
using Yavsc.Helpers;
public class AccountController : Controller
{
@ -212,19 +215,30 @@ namespace Yavsc.Controllers
var result = await _userManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
user.DiskQuota = Startup.SiteSetup.UserFiles.Quota;
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
// Send an email with this link
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
await _emailSender.SendEmailAsync(_siteSettings, _smtpSettings, model.Email, "Confirm your account",
"Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
// await _signInManager.SignInAsync(user, isPersistent: false);
_logger.LogInformation(3, "User created a new account with password.");
await _emailSender.SendEmailAsync(_siteSettings, _smtpSettings, Startup.SiteSetup.Owner.EMail,
$"[{_siteSettings.Title}] Inscription avec mot de passe: {user.UserName} ", $"{user.Id}/{user.UserName}/{user.Email}");
return RedirectToAction(nameof(HomeController.Index), "Home");
// TODO user.DiskQuota = Startup.SiteSetup.UserFiles.Quota;
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
// Send an email with this link
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
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",
"Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
await _signInManager.SignInAsync(user, isPersistent: false);
if (!emailSent) {
_logger.LogWarning("User created with error sending email confirmation request");
this.NotifyWarning (
"E-mail confirmation",
_localizer["ErrorSendingEmailForConfirm"]
) ;
} else this.NotifyInfo (
"E-mail confirmation",
_localizer["EmailSentForConfirm"]
) ;
return View("AccountCreated");
}
AddErrors(result);
}

View File

@ -16,6 +16,7 @@ namespace Yavsc.Controllers
using System.IO;
using Models;
using Yavsc;
using Yavsc.Helpers;
[AllowAnonymous]
public class HomeController : Controller
@ -51,7 +52,7 @@ namespace Yavsc.Controllers
var notes = DbContext.Notification.Where(
n=> !clicked.Any(c=>n.Id==c)
);
ViewData["Notify"] = notes;
this.Notify(notes);
ViewData["HasHaircutCommand"] = DbContext.HairCutQueries.Any
(q=>q.ClientId == uid && q.Status < QueryStatus.Failed);