Avoid spaces in user names

[TODO] fix identity config
vnext
Paul Schneider 5 years ago
parent 7143c1feeb
commit 4013d7f248
7 changed files with 33 additions and 18 deletions

@ -7,11 +7,14 @@ namespace Yavsc.Attributes.Validation
public class YaRegularExpression : System.ComponentModel.DataAnnotations.RegularExpressionAttribute {
public YaRegularExpression(string pattern): base (pattern)
{
this.ErrorMessage = pattern;
this.ErrorMessage = "RegularExpression: "+ pattern;
}
public override string FormatErrorMessage(string name)
{
if (ErrorMessageResourceType==null || string.IsNullOrEmpty(ErrorMessageResourceName))
return ErrorMessage;
var prop = this.ErrorMessageResourceType.GetProperty(ErrorMessageResourceName);
return (string) prop.GetValue(null, BindingFlags.Static, null, null, System.Globalization.CultureInfo.CurrentUICulture);

@ -51,7 +51,6 @@ namespace Yavsc.Attributes.Validation
}
public override string FormatErrorMessage(string name)
{
var temp = base.FormatErrorMessage(name);
return string.Format(temp, MinimumLength, maxLen);
}

@ -36,7 +36,9 @@ namespace Yavsc.Attributes.Validation
public override string FormatErrorMessage(string name)
{
if (ErrorMessageResourceType == null) // failed :/
{
return base.FormatErrorMessage(name);
}
if (ErrorMessageResourceName == null) // re failed :/
return base.FormatErrorMessage(name);

@ -1,12 +1,14 @@
using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account
{
public class ExternalLoginConfirmationViewModel
{
[Required]
[YaStringLength(2,Constants.MaxUserNameLength)]
[YaRegularExpression(Constants.UserNameRegExp)]
public string Name { get; set; }
[Required]

@ -504,7 +504,10 @@ namespace Yavsc.Controllers
// 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.GeneratePasswordResetTokenAsync(user);
var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: "https");
var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code },
protocol: "https", host: Startup.Authority);
await _emailSender.SendEmailAsync(user.UserName, user.Email, _localizer["Reset Password"],
_localizer["Please reset your password by following this link:"] + " <" + callbackUrl + ">");
return View("ForgotPasswordConfirmation");

@ -1,7 +1,6 @@
DESTDIR=/srv/www/yavscpre
PRODDESTDIR=/srv/www/yavsc
DESTDIR=/var/www/yavscpre
PRODDESTDIR=/var/www/yavsc
HOSTING=localhost
HOSTADMIN=root
ASPNET_LOG_LEVEL=debug
SOURCE_DIR=$(HOME)/workspace/yavsc
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/build/make
@ -22,6 +21,13 @@ MINCSS=wwwroot/css/coiffure.min.css wwwroot/css/dev.min.css wwwroot/c
web: project.lock.json
ASPNET_LOG_LEVEL=$(ASPNET_LOG_LEVEL) ASPNET_ENV=$(ASPNET_ENV) dnx web --configuration=$(CONFIGURATION)
showConfig:
@echo HOSTING: $(USER)@$(HOSTING)
@echo ENV: $(ASPNET_ENV)
@echo CONFIGURATION: $(CONFIGURATION)
@echo DESTDIR: $(DESTDIR)
@echo PRODDESTDIR: $(PRODDESTDIR)
status:
ifeq ($(git_status),0)
@echo Nothing to be done.
@ -38,19 +44,19 @@ deploy-pkg: publish
deploy: pushInPre pushInProd
pushInPre: cleanoutput bin/output/wwwroot/version
ssh $(HOSTADMIN)@$(HOSTING) sudo service kestrel-pre stop
ssh $(HOSTADMIN)@$(HOSTING) sudo rm -rf $(DESTDIR)/approot
(cd bin/output && rsync -ravu ./ $(HOSTADMIN)@$(HOSTING):$(DESTDIR) >/dev/null)
ssh $(HOSTADMIN)@$(HOSTING) sudo sync
ssh $(HOSTADMIN)@$(HOSTING) sudo service kestrel-pre start
ssh $(USER)@$(HOSTING) sudo service kestrel-pre stop
ssh $(USER)@$(HOSTING) sudo rm -rf $(DESTDIR)/approot
(cd bin/output && rsync -ravu ./ $(USER)@$(HOSTING):$(DESTDIR) >/dev/null)
ssh $(USER)@$(HOSTING) sudo sync
ssh $(USER)@$(HOSTING) sudo service kestrel-pre start
pushInProd: cleanoutput bin/output/wwwroot/version
ifeq ($(git_status),0)
ssh $(HOSTADMIN)@$(HOSTING) sudo service kestrel stop
ssh $(HOSTADMIN)@$(HOSTING) sudo rm -rf $(PRODDESTDIR)/approot
(cd bin/output && rsync -ravu ./ $(HOSTADMIN)@$(HOSTING):$(PRODDESTDIR) >/dev/null)
ssh $(HOSTADMIN)@$(HOSTING) sudo sync
ssh $(HOSTADMIN)@$(HOSTING) sudo service kestrel start
ssh $(USER)@$(HOSTING) sudo service kestrel stop
ssh $(USER)@$(HOSTING) sudo rm -rf $(PRODDESTDIR)/approot
(cd bin/output && rsync -ravu ./ $(USER)@$(HOSTING):$(PRODDESTDIR) >/dev/null)
ssh $(USER)@$(HOSTING) sudo sync
ssh $(USER)@$(HOSTING) sudo service kestrel start
else
$(error EPRODANDGITSTATUS! Refus de pousser en production: des changements doivent être validés auprès du contrôle de versions.)
git status

@ -4,7 +4,7 @@
}
<h2>@ViewData["Title"].</h2>
<h3>Assoiciez votre compte @ViewData["LoginProvider"].</h3>
<h3>Associez votre compte @ViewData["LoginProvider"].</h3>
<form asp-controller="Account" asp-action="ExternalLoginConfirmation" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="form-horizontal" role="form">
<h4>Formulaire d'Association</h4>

Loading…