diff --git a/src/Yavsc.Abstract/Authentication/RegisterViewModel.cs b/src/Yavsc.Abstract/Authentication/RegisterViewModel.cs index 861813ce..69941952 100644 --- a/src/Yavsc.Abstract/Authentication/RegisterViewModel.cs +++ b/src/Yavsc.Abstract/Authentication/RegisterViewModel.cs @@ -8,27 +8,28 @@ namespace Yavsc.ViewModels.Account public class RegisterModel { - [YaStringLength(2,Constants.MaxUserNameLength)] - [YaRegularExpression(Constants.UserNameRegExp)] + [StringLength(Constants.MaxUserNameLength)] + [RegularExpression(Constants.UserNameRegExp)] + [DataType(DataType.Text)] + [Display(Name = "UserName", Description = "User name")] public string UserName { get; set; } - [YaRequired()] - [YaStringLength(2,102)] + [Required()] + [StringLength( maximumLength:102, MinimumLength = 5)] // [EmailAddress] - [Display(Name = "Email")] + [Display(Name = "Email", Description = "E-Mail")] public string Email { get; set; } - [YaStringLength(6,100)] + [StringLength(maximumLength:100, MinimumLength = 6, + ErrorMessage = "Le mot de passe doit contenir au moins 8 caratères")] [DataType(DataType.Password)] - - // ErrorMessage = "Les mots de passe doivent contenir au moins un caractère spécial, qui ne soit ni une lettre ni un chiffre.")] - + [Display(Name = "Password")] public string Password { get; set; } [DataType(DataType.Password)] [Compare("Password")] + [Display(Name = "ConfirmPassword", Description ="Password Confirmation")] public string ConfirmPassword { get; set; } - } } diff --git a/src/Yavsc.Abstract/Constants.cs b/src/Yavsc.Abstract/Constants.cs index b55a3ee5..8a37bd29 100644 --- a/src/Yavsc.Abstract/Constants.cs +++ b/src/Yavsc.Abstract/Constants.cs @@ -19,23 +19,15 @@ namespace Yavsc public const string CompanyClaimType = "https://schemas.pschneider.fr/identity/claims/Company"; public const string UserNameRegExp = @"^[a-zA-Z][a-zA-Z0-9._-]*$"; public const string UserFileNamePatternRegExp = @"^([a-zA-Z0-9._-]*/)*[a-zA-Z0-9._-]+$"; - public const string AuthorizePath = "/authorize"; - public const string TokenPath = "/token"; + public const string LoginPath = "/signin"; public const string LogoutPath = "/signout"; - - public const string SignalRPath = "/api/signalr"; public const string UserFilesPath = "/files"; public const string AvatarsPath = "/avatars"; public const string GitPath = "/sources"; - public const string LiveUserPath = "live"; - - public const string ApplicationAuthenticationSheme = "ServerCookie"; - public const string ExternalAuthenticationSheme = "ExternalCookie"; public const string DefaultFactor = "Default"; public const string MobileAppFactor = "Mobile Application"; - public const string EMailFactor = "Email"; public const string SMSFactor = "SMS"; public const string AdminGroupName = "Administrator"; public const string PerformerGroupName = "Performer"; diff --git a/src/Yavsc/Controllers/Accounting/AccountController.cs b/src/Yavsc/Controllers/Accounting/AccountController.cs index 7c2ae269..000a8138 100644 --- a/src/Yavsc/Controllers/Accounting/AccountController.cs +++ b/src/Yavsc/Controllers/Accounting/AccountController.cs @@ -157,40 +157,7 @@ namespace Yavsc.Controllers // only set explicit expiration here if user chooses "remember me". // otherwise we rely upon expiration configured in cookie middleware. - AuthenticationProperties props = null; - if (AccountOptions.AllowRememberLogin && model.RememberLogin) - { - props = new AuthenticationProperties - { - IsPersistent = true, - ExpiresUtc = DateTimeOffset.UtcNow.Add(AccountOptions.RememberMeLoginDuration), - // Parameters = - }; - }; - - // roles - var roles = _dbContext.UserRoles.Where(r=>r.UserId == user.Id).ToArray(); - - // issue authentication cookie with subject ID and username - - List additionalClaims = new List(); - - foreach (var role in roles) - { - var idRole = await _roleManager.Roles.SingleOrDefaultAsync(i=>i.Id == role.RoleId); - if (idRole != null) - { - additionalClaims.Add(new Claim(ClaimTypes.Role, idRole.Name)); - } - } - additionalClaims.Add(new Claim(ClaimTypes.Name, user.UserName)); - var isUser = new IdentityServerUser(user.Id) - { - DisplayName = user.UserName, - AdditionalClaims = additionalClaims.ToArray() - }; - - await HttpContext.SignInAsync(isUser, props); + await HttpContext.SignInAsync(user, _roleManager, model.RememberLogin,_dbContext); if (context != null) { @@ -231,7 +198,6 @@ namespace Yavsc.Controllers return View(vm); } - /// /// Show logout page /// diff --git a/src/Yavsc/Controllers/Accounting/ManageController.cs b/src/Yavsc/Controllers/Accounting/ManageController.cs index 9e4002a0..ab12234d 100644 --- a/src/Yavsc/Controllers/Accounting/ManageController.cs +++ b/src/Yavsc/Controllers/Accounting/ManageController.cs @@ -392,13 +392,13 @@ namespace Yavsc.Controllers return RedirectToAction(nameof(Index), new { Message = ManageMessageId.Error }); } - public IActionResult ChangeUserName() + public IActionResult SetUserName() { - return View(new ChangeUserNameViewModel() { NewUserName = User.Identity.Name }); + return View(new SetUserNameViewModel() { UserName = User.Identity.Name }); } [HttpPost] - public async Task ChangeUserName(ChangeUserNameViewModel model) + public async Task SetUserName(SetUserNameViewModel model) { if (!ModelState.IsValid) { @@ -409,7 +409,7 @@ namespace Yavsc.Controllers { var oldUserName = user.UserName; - var result = await this._userManager.SetUserNameAsync(user, model.NewUserName); + var result = await this._userManager.SetUserNameAsync(user, model.UserName); if (result.Succeeded) { @@ -418,7 +418,7 @@ namespace Yavsc.Controllers Path.Combine(_siteSettings.Blog, oldUserName)); var newdir = Path.Combine(_siteSettings.Blog, - model.NewUserName); + model.UserName); if (userdirinfo.Exists) userdirinfo.MoveTo(newdir); // Renames the Avatars files @@ -429,7 +429,7 @@ namespace Yavsc.Controllers oldUserName+s)); if (fi.Exists) fi.MoveTo(Path.Combine(_siteSettings.Avatars, - model.NewUserName+s)); + model.UserName+s)); } await _signInManager.SignInAsync(user, isPersistent: false); _logger.LogInformation(3, "User changed his user name successfully."); diff --git a/src/Yavsc/Controllers/Contracting/EstimateController.cs b/src/Yavsc/Controllers/Contracting/EstimateController.cs index b36d5ea4..a9040362 100644 --- a/src/Yavsc/Controllers/Contracting/EstimateController.cs +++ b/src/Yavsc/Controllers/Contracting/EstimateController.cs @@ -152,10 +152,6 @@ namespace Yavsc.Controllers { return NotFound(); } - - ViewBag.Files = Yavsc.Helpers.FileSystemHelpers.GetFileName(null); - - // Yavsc.Helpers.GetUserFiles(User, null); return View(estimate); } diff --git a/src/Yavsc/Controllers/HomeController.cs b/src/Yavsc/Controllers/HomeController.cs index 097ffcf5..72c7f0d4 100644 --- a/src/Yavsc/Controllers/HomeController.cs +++ b/src/Yavsc/Controllers/HomeController.cs @@ -67,8 +67,7 @@ namespace Yavsc.Controllers } public async Task About() { - FileInfo fi = new FileInfo("wwwroot/version"); - return View("About", fi.Exists ? _localizer["Version logicielle: "] + await fi.OpenText().ReadToEndAsync() : _localizer["Aucune information sur la version logicielle n'est publiée."]); + return View("About"); } public IActionResult Privacy() { diff --git a/src/Yavsc/Extensions/HostingExtensions.cs b/src/Yavsc/Extensions/HostingExtensions.cs index 2f88c5fd..493f84f3 100644 --- a/src/Yavsc/Extensions/HostingExtensions.cs +++ b/src/Yavsc/Extensions/HostingExtensions.cs @@ -1,9 +1,6 @@ using System.Globalization; -using System.Security.Permissions; -using Google.Apis.Auth.OAuth2; using Google.Apis.Util.Store; using IdentityServer4; -using IdentityServer4.Test; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.DataProtection; @@ -11,7 +8,6 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Razor; -using Microsoft.AspNetCore.StaticFiles; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Localization; @@ -25,7 +21,6 @@ using Yavsc.Interface; using Yavsc.Models; using Yavsc.Models.Billing; using Yavsc.Models.Haircut; -using Yavsc.Models.Market; using Yavsc.Models.Workflow; using Yavsc.Services; using Yavsc.Settings; @@ -36,8 +31,7 @@ namespace Yavsc.Extensions; internal static class HostingExtensions { - - public static IApplicationBuilder ConfigureFileServerApp(this IApplicationBuilder app, + public static IApplicationBuilder ConfigureFileServerApp(this IApplicationBuilder app, bool enableDirectoryBrowsing = false) { @@ -180,8 +174,9 @@ internal static class HostingExtensions .AddEntityFrameworkStores() .AddDefaultTokenProviders(); - services - .AddIdentityServer(options => + + + services.AddIdentityServer(options => { options.Events.RaiseErrorEvents = true; options.Events.RaiseInformationEvents = true; @@ -194,7 +189,7 @@ internal static class HostingExtensions .AddInMemoryIdentityResources(Config.IdentityResources) .AddInMemoryApiScopes(Config.ApiScopes) .AddInMemoryClients(Config.Clients) - .AddDeveloperSigningCredential() + .AddAspNetIdentity() ; services.AddSession(); diff --git a/src/Yavsc/Extensions/HttpContextExtensions.cs b/src/Yavsc/Extensions/HttpContextExtensions.cs new file mode 100644 index 00000000..235ec277 --- /dev/null +++ b/src/Yavsc/Extensions/HttpContextExtensions.cs @@ -0,0 +1,54 @@ + +using System.Security.Claims; +using IdentityServer4; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; +using Yavsc.Models; +using Yavsc.Models.Access; + +namespace Yavsc.Extensions; + +internal static class HttpContextExtensions +{ + public static async Task SignInAsync(this HttpContext context, + ApplicationUser user, RoleManager roleManager, + bool rememberMe, + ApplicationDbContext applicationDbContext) + { + AuthenticationProperties props = null; + if (AccountOptions.AllowRememberLogin && rememberMe) + { + props = new AuthenticationProperties + { + IsPersistent = true, + ExpiresUtc = DateTimeOffset.UtcNow.Add(AccountOptions.RememberMeLoginDuration), + // Parameters = + }; + }; + + // roles + var roles = applicationDbContext.UserRoles.Where(r => r.UserId == user.Id).ToArray(); + + // issue authentication cookie with subject ID and username + + List additionalClaims = new List(); + + foreach (var role in roles) + { + var idRole = await roleManager.Roles.SingleOrDefaultAsync(i => i.Id == role.RoleId); + if (idRole != null) + { + additionalClaims.Add(new Claim(ClaimTypes.Role, idRole.Name)); + } + } + additionalClaims.Add(new Claim(ClaimTypes.Name, user.UserName)); + var isUser = new IdentityServerUser(user.Id) + { + DisplayName = user.UserName, + AdditionalClaims = additionalClaims.ToArray() + }; + + await context.SignInAsync(isUser, props); + } +} diff --git a/src/Yavsc/Helpers/FileSystemHelpers.cs b/src/Yavsc/Helpers/FileSystemHelpers.cs index 0ab69340..8d6f7385 100644 --- a/src/Yavsc/Helpers/FileSystemHelpers.cs +++ b/src/Yavsc/Helpers/FileSystemHelpers.cs @@ -65,6 +65,11 @@ namespace Yavsc.Helpers } } + public static string GetAvatarUri(this ApplicationUser user) + { + return $"/{Config.SiteSetup.Avatars}/{user.UserName}.png"; + } + public static string InitPostToFileSystem( this ClaimsPrincipal user, string subpath) diff --git a/src/Yavsc/ViewModels/Manage/ChangeUserNameViewModel.cs b/src/Yavsc/ViewModels/Manage/ChangeUserNameViewModel.cs deleted file mode 100644 index 8299c727..00000000 --- a/src/Yavsc/ViewModels/Manage/ChangeUserNameViewModel.cs +++ /dev/null @@ -1,14 +0,0 @@ - -using System.ComponentModel.DataAnnotations; -using Yavsc.Attributes.Validation; - -namespace Yavsc.ViewModels.Manage -{ - public class ChangeUserNameViewModel - { - [YaRequired] - [Display(Name = "New user name"),RegularExpression(Constants.UserNameRegExp)] - public string NewUserName { get; set; } - - } -} diff --git a/src/Yavsc/ViewModels/Manage/SetUserNameViewModel.cs b/src/Yavsc/ViewModels/Manage/SetUserNameViewModel.cs new file mode 100644 index 00000000..61cf0727 --- /dev/null +++ b/src/Yavsc/ViewModels/Manage/SetUserNameViewModel.cs @@ -0,0 +1,14 @@ + +using System.ComponentModel.DataAnnotations; +using Yavsc.Attributes.Validation; + +namespace Yavsc.ViewModels.Manage +{ + public class SetUserNameViewModel + { + [Required] + [Display(Name = "User name"),RegularExpression(Constants.UserNameRegExp)] + public string UserName { get; set; } + + } +} diff --git a/src/Yavsc/Views/Account/Register.cshtml b/src/Yavsc/Views/Account/Register.cshtml new file mode 100644 index 00000000..388b2ecd --- /dev/null +++ b/src/Yavsc/Views/Account/Register.cshtml @@ -0,0 +1,8 @@ +@model RegisterModel + + +
+ @Html.EditorForModel() + +
diff --git a/src/Yavsc/Views/Blogspot/Details.cshtml b/src/Yavsc/Views/Blogspot/Details.cshtml index 65ab92ce..64471a1e 100644 --- a/src/Yavsc/Views/Blogspot/Details.cshtml +++ b/src/Yavsc/Views/Blogspot/Details.cshtml @@ -69,22 +69,7 @@ $('span.field-validation-valid[data-valmsg-for="Content"]').html(

@Model.Title

- @Html.AsciiDocFor(model => model.Content) -

-
- -
- @Html.DisplayFor(model => model.Author) - - @Html.DisplayNameFor(model => model.DateModified) : - - @Html.DisplayFor(model => model.DateModified) - - @Html.DisplayNameFor(model => model.DateCreated) : - - @Html.DisplayFor(model => model.DateCreated) - - @await Component.InvokeAsync("Tagger",Model) + @Html.DisplayForModel()
diff --git a/src/Yavsc/Views/Home/About.cshtml b/src/Yavsc/Views/Home/About.cshtml index 264cf39a..c288fb44 100755 --- a/src/Yavsc/Views/Home/About.cshtml +++ b/src/Yavsc/Views/Home/About.cshtml @@ -1,14 +1,10 @@ @using System.Diagnostics -@{ - ViewData["Title"] = SR["About"] + " " + SiteSettings.Value.Title; -} -

@ViewData["Title"]

+ +

@SiteSettings.Value.Title - À Propos

**Version de Development** -= À propos de Yavsc - == L'objectif Cette application est construite pour mettre en relation des artistes @@ -91,38 +87,4 @@ et programme la suppression complète de ces dites informations dans les quinze à compter de la demande, sauf demande contradictoire. L'opération est annulable, jusqu'à deux semaines après sa programmation. -

-@Model -

- -@{ - var version = FileVersionInfo.GetVersionInfo(typeof(IdentityServer4.Hosting.IdentityServerMiddleware).Assembly.Location).ProductVersion.Split('+').First(); -} - -
-

- - Welcome to IdentityServer4 - (version @version) -

- - -
- +

@Model

diff --git a/src/Yavsc/Views/Home/About.pt.cshtml b/src/Yavsc/Views/Home/About.pt.cshtml index 6d02607e..85b4d291 100755 --- a/src/Yavsc/Views/Home/About.pt.cshtml +++ b/src/Yavsc/Views/Home/About.pt.cshtml @@ -1,16 +1,13 @@ -@{ - ViewData["Title"] = @SR["About"]+" "+@SiteSettings.Value.Title; -} -

@ViewData["Title"]

+

@SiteSettings.Value.Title - objetivo

-## O objetivo += O objetivo Esta aplicação é construída para conectar artistas do campo musical com seu público. -## Operation +== Operation Os usuários do site são artista, cliente ou administrador. Todos eles têm direito ao seu blog. Para artistas, é uma maneira de promover seus negócios. @@ -52,7 +49,7 @@ Depois que o serviço associado tiver sido executado, os pagamentos relativos se Para um contrato executado e não honrado pelo cliente, o processo de processo de recuperação é contratado, caso contrário, o contrato é arquivado, Os certificados de pagamento estão disponíveis para o artista e a fatura é marcada como paga e depois repassada ao cliente. -### Para o artista +=== Para o artista O artista escolhe vários parâmetros que farão o seu perfil: @@ -65,7 +62,7 @@ O artista escolhe vários parâmetros que farão o seu perfil: * Parâmetros adicionais dependendo do tipo de atividade, por exemplo, para conjuntos, seu tamanho, se houver, seu repertório ou indicações do estilo de sua música) -### Para o cliente +=== Para o cliente Ele escolhe um lugar e uma data para declarar um evento futuro (Ele pode programar o quanto quiser). @@ -75,7 +72,7 @@ com base em um de seus projetos de eventos, a negociação de um contrato de ser Ele tem acesso ao conhecimento de dias conhecidos como artistas livres pelo sistema. -## Confidencialidade +== Confidencialidade Em nenhum momento, nenhum endereço de correspondência, nenhum endereço de e-mail e nenhum número de telefone não são transmitidos para clientes ou artistas. Apenas o sistema tem acesso a essas informações. @@ -158,6 +155,4 @@ A "pré-produção" exibe os seguintes sites: -

-@Model -

+

@Model

diff --git a/src/Yavsc/Views/Home/AboutIdentityServer.cshtml b/src/Yavsc/Views/Home/AboutIdentityServer.cshtml new file mode 100644 index 00000000..36b2bfc3 --- /dev/null +++ b/src/Yavsc/Views/Home/AboutIdentityServer.cshtml @@ -0,0 +1,32 @@ +@using System.Diagnostics + +@{ + var version = FileVersionInfo.GetVersionInfo(typeof(IdentityServer4.Hosting.IdentityServerMiddleware).Assembly.Location).ProductVersion.Split('+').First(); +} + +
+

+ + Welcome to IdentityServer4 + (version @version) +

+ + +
diff --git a/src/Yavsc/Views/Manage/Index.cshtml b/src/Yavsc/Views/Manage/Index.cshtml index e5a4d8ae..64a173b1 100755 --- a/src/Yavsc/Views/Manage/Index.cshtml +++ b/src/Yavsc/Views/Manage/Index.cshtml @@ -14,18 +14,19 @@
@Model.UserName + [modifier]
-
EMail:
+
E-mail
@Model.EMail @if (Model.EmailConfirmed) { - (Adresse E-mail confirmée"]) + (Adresse E-mail confirmée) } else { - (Adresse non confirmée."]) + (Adresse non confirmée.)
@@ -35,7 +36,7 @@
-
AllowMonthlyEmail:
+
Allow Monthly Email
@Html.DisplayFor(m=>m.AllowMonthlyEmail) [modifier] @@ -46,7 +47,8 @@
FullName:
- @Html.DisplayFor(m=>m.FullName) [modifier] + @Html.DisplayFor(m=>m.FullName) + [modifier]
@if (Model.Roles.Count()>0) { diff --git a/src/Yavsc/Views/Manage/ChangeUserName.cshtml b/src/Yavsc/Views/Manage/SetUserName.cshtml similarity index 51% rename from src/Yavsc/Views/Manage/ChangeUserName.cshtml rename to src/Yavsc/Views/Manage/SetUserName.cshtml index 06e960ee..9a0c4cec 100644 --- a/src/Yavsc/Views/Manage/ChangeUserName.cshtml +++ b/src/Yavsc/Views/Manage/SetUserName.cshtml @@ -1,19 +1,19 @@ -@model ChangeUserNameViewModel +@model SetUserNameViewModel @{ ViewData["Title"] = "Changer de nom d'utilisateur"; }

@ViewData["Title"].

-
+

Change user name form


- +
- - + +
diff --git a/src/Yavsc/Views/Shared/Components/BlogIndex/Default.cshtml b/src/Yavsc/Views/Shared/Components/BlogIndex/Default.cshtml index f0a9ab4d..9a2f3310 100644 --- a/src/Yavsc/Views/Shared/Components/BlogIndex/Default.cshtml +++ b/src/Yavsc/Views/Shared/Components/BlogIndex/Default.cshtml @@ -34,7 +34,7 @@ @item.Content @if (trunked) { ... } - (@item.Author.UserName , + (@Html.DisplayFor(m => item.Author), posté le @item.DateCreated.ToString("dddd d MMM yyyy à H:mm") @if ((item.DateModified - item.DateCreated).Minutes > 0){  diff --git a/src/Yavsc/Views/Shared/DisplayTemplates/ApplicationUser.cshtml b/src/Yavsc/Views/Shared/DisplayTemplates/ApplicationUser.cshtml index 13b27cdc..8fc95062 100644 --- a/src/Yavsc/Views/Shared/DisplayTemplates/ApplicationUser.cshtml +++ b/src/Yavsc/Views/Shared/DisplayTemplates/ApplicationUser.cshtml @@ -1,12 +1,14 @@ @model ApplicationUser @{ var avuri = "/Avatars/"+Model.UserName+".s.png"; + var userPosted = Model.Posts!=null && Model.Posts.Count()>1; }
-

- -

-@if (Model.Posts!=null && Model.Posts.Count()>1) { index de ses articles +@if (userPosted) { + + +}else { + Html.LabelFor(m=>m.UserName); }
diff --git a/src/Yavsc/Views/_ViewImports.cshtml b/src/Yavsc/Views/_ViewImports.cshtml index fb3c305e..8b6f0199 100755 --- a/src/Yavsc/Views/_ViewImports.cshtml +++ b/src/Yavsc/Views/_ViewImports.cshtml @@ -35,7 +35,7 @@ @addTagHelper *, Yavsc @inject IAuthorizationService AuthorizationService -@inject Microsoft.AspNetCore.Mvc.Localization.IHtmlLocalizer SR +@inject Microsoft.AspNetCore.Mvc.Localization.IHtmlLocalizer SR @inject Microsoft.Extensions.Options.IOptions SiteSettings @inject SignInManager SignInManager @inject UserManager UserManager diff --git a/src/Yavsc/Yavsc.csproj b/src/Yavsc/Yavsc.csproj index 51a096ab..7746b6f6 100644 --- a/src/Yavsc/Yavsc.csproj +++ b/src/Yavsc/Yavsc.csproj @@ -13,6 +13,7 @@ all +