diff --git a/Yavsc/Controllers/AccountController.cs b/Yavsc/Controllers/AccountController.cs index 0cadcc73..8c16babc 100644 --- a/Yavsc/Controllers/AccountController.cs +++ b/Yavsc/Controllers/AccountController.cs @@ -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; + _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}"); + + // 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); - await _emailSender.SendEmailAsync(_siteSettings, _smtpSettings, model.Email, "Confirm your account", + var emailSent = await _emailSender.SendEmailAsync(_siteSettings, _smtpSettings, model.Email, "Confirm your account", "Please confirm your account by clicking this link: link"); - // 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"); + 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); } diff --git a/Yavsc/Controllers/HomeController.cs b/Yavsc/Controllers/HomeController.cs index 8d894062..9eb31e16 100644 --- a/Yavsc/Controllers/HomeController.cs +++ b/Yavsc/Controllers/HomeController.cs @@ -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); diff --git a/Yavsc/Helpers/ControllerHelpers.cs b/Yavsc/Helpers/ControllerHelpers.cs new file mode 100644 index 00000000..44878132 --- /dev/null +++ b/Yavsc/Helpers/ControllerHelpers.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using Microsoft.AspNet.Mvc; +using Yavsc.Models.Messaging; + +namespace Yavsc.Helpers +{ + public static class ControllerHelpers + { + public static void NotifyWarning(this Controller controller, string title, string body) + { + var notifs = SetupNotificationList(controller); + notifs.Add(new Notification { title = title, body = body }); + } + public static void NotifyInfo(this Controller controller, string title, string body) + { + var notifs = SetupNotificationList(controller); + notifs.Add(new Notification { title = title, body = body }); + } + public static void Notify(this Controller controller, IEnumerable notes) + { + var notifs = SetupNotificationList(controller); + notifs.AddRange(notes); + } + private static List SetupNotificationList(this Controller controller) + { + List notifs = (List)controller.ViewData["Notify"]; + if (notifs == null) + { + controller.ViewData["Notify"] = notifs = new List(); + } + return notifs; + } + + } +} \ No newline at end of file diff --git a/Yavsc/Models/ApplicationDbContext.cs b/Yavsc/Models/ApplicationDbContext.cs index 21dcac96..42982088 100644 --- a/Yavsc/Models/ApplicationDbContext.cs +++ b/Yavsc/Models/ApplicationDbContext.cs @@ -54,7 +54,7 @@ namespace Yavsc.Models builder.Entity().HasKey(l=>new { l.HRef, l.Method }); builder.Entity().HasKey(l=>new { l.Start, l.End }); builder.Entity().HasKey( o => new { o.Code, o.CodeScrutin }); - + builder.Entity().Property(n=> n.icon).HasDefaultValue("exclam"); foreach (var et in builder.Model.GetEntityTypes()) { if (et.ClrType.GetInterface("IBaseTrackedEntity")!=null) et.FindProperty("DateCreated").IsReadOnlyAfterSave = true; diff --git a/Yavsc/Models/Messaging/Notification.cs b/Yavsc/Models/Messaging/Notification.cs index f2299ad7..880632d2 100644 --- a/Yavsc/Models/Messaging/Notification.cs +++ b/Yavsc/Models/Messaging/Notification.cs @@ -25,7 +25,7 @@ namespace Yavsc.Models.Messaging /// The icon. /// [Display(Name = "Icône")] - public string icon { get; set; } + public string icon { get; set; } /// /// The sound. /// @@ -55,5 +55,10 @@ namespace Yavsc.Models.Messaging /// /// public string Target { get; set; } + + public Notification() + { + icon = "exclam"; + } } } diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx index 18b70192..de8d8e65 100644 --- a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx +++ b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx @@ -13,19 +13,7 @@ Example: ... ado.net/XML headers & schema ... - text/microsoft-resx - 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, ... - System.Resources.ResXResourceWriter, System.Windows.Forms, ... - this is my long stringthis is a comment - Blue - - [base64 mime encoded serialized .NET Framework object] - - - [base64 mime encoded string representing a byte array form of the .NET Framework object] - This is a comment - + text/microsoft-resx2.0System.Resources.ResXResourceReader, System.Windows.Forms, ...System.Resources.ResXResourceWriter, System.Windows.Forms, ...this is my long stringthis is a commentBlue[base64 mime encoded serialized .NET Framework object][base64 mime encoded string representing a byte array form of the .NET Framework object]This is a comment There are any number of "resheader" rows that contain simple name/value pairs. @@ -59,7 +47,10 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - + @@ -117,238 +108,670 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - About - About BookAStar - Welcome by your stars. - Access denied - Account Balance - Activity - Activities - additionally - Allow my geolocatisation, nearby my clients - An instant message has been sent to {0}, - showing to him your query. You should be contacted very soon. - a prestation - Ask for an estimate - Attached files - You must be authenticated in order to access this information - Author - available - Basket - Bill edition - Bill removal - Bill access control - Bill created - Bill source code - Bill updated - body - Book an artist - Book a performer in information technology - Book an artiste - Book a software editor - Catalog - Change user name form - Change your account settings - Please, choose a description - Please, choose a title - Please, Choose A Date In The Futur - Please, choose a date for this event - Ciffer - Circles - Click action - Color - Comment - Consultant - Contact a performer - Could not convert '{0}' to double. - Count - Créer - Credits - Date search - Data base - Description - Disable - Display Name - Do an estimate - Commenter - Une erreur est survenue à la génération de votre document - Ne pas publier mon activité - Do post - S'il vous plait, spécifiez ceux de vos cercles à qui est destiné ce contenu - Tagger - This email adress is already used ({0}). - This user name is already used ({0}). - Edit - Edited - Edit related skills - Date de fin - Heure de fin - e-mail - - Generated e-mail from {0}, because of your perfomer profile publication, - and your email usage agreement. - Visit {1} to modify your profile, unsubscribe or unregister. - entries - Estimate not found - Estimate wanted - Event Web page - Existant data base - External Logins - Please, use a date in the future as starting date. - Restricted area - from - Tell more, below, about your query - Google could'nt identify this place - Google calendar - Google error : {0} - Google registration id - Home - Hide - hidden - Hide the bill source text - I understood - Icons made by - Image URI - Exception at importing - Internal Server Error - is licensed by - Item added to basket - Location - Login - Logout - Main activity - Manage - Site skills - Maximal date for the rendez-vous - Mainly Exerted Activity code - Manage your account - Members - Your message has been sent. - Minimal date for the rendez-vous - Modify - My estimates - Name - Needs - Need - new instrument - - New display name - New display name - New Tag - A message had been sent, containing a link to follow in order - to update your password. - no content - No skill was informed by any performer for this activity - none - Non existent user - Not Approuved - No calendar was associated to this user. - Offline - Online - Only authorized users may contact a performer by mail. - Pdf version - Performance date - Performance place - Performers - Performer - Person - Photo - Photo updated - Please check your email to reset your password. - Please confirm your new password - Please fill in a body - Please, fill in a reason - - Posted - Prefered date - prestation - Presation location:{0}.\n - Previewcomment on preview - Profile edition - Private circle - Provider identifier - Provider name - Product_reference - Read more ... - reason - Register - Registration: unexpected error occured: - "{0}". - Please forgive for troubles - Remember me - Remove - Reset your password - Role - role created - Role name - Save these settings - Search - Talents/Compétences/Spécialités gérés sur ce site - Skill - Skills - Please, specify a valid latitude - Please, specify a valid longitude - Specify a latitude - Specify a longitude - Please, specify a place - {0} would want you to establish an estimate concerning {1} - Sound - Start date - The ending date must be later than the starting one. - Start hour - Submit - Submit changes - Tag - Tag name - LaTeX version - This site uses cookies - ThisPerformer Gives access to his calendar and seems to be available this - This performer gives access to his calendar and it appears he should not be available this - ThisPerformerDoesntGiveAccessToHisCalendar - Title - to - Two-Factor authentication - - Unitary_cost - Unregister - User List - User name - List of users assuming the role "{0}" - This user is not in this role - User skills - View source - was added to the role - There was no user in the "{1}" role. You ({0}) was just added as firt user in the "{1}" role. - Welcome - {0} has been notified of your query, you should be fast contacted - regarding his calendar, -{0} should be available for this booking - Paramètres musicien (l'instrument) - Paramètres Dj (le compte SoundCloud.com) - Paramètres formation (les partenaires) - Paramètres généraux: une couleur musicale - You need to be authenticated in order to -contact a performer - You're not administrator - Your estimates - Your activity - Your need - your query has been transmitted - Your skills, your special fields, the scope of your activities - You posts - Your profile - Your message has been sent - Hair Length - French - English - This field is required. - Passwords must be at least {0} characters. - Passwords must have at least one non letter and non digit character. - Passwords must have at least one digit ('0'-'9'). - Passwords must have at least one uppercase ('A'-'Z'). - Passwords and confirmation are not the same. -Password confirmation - Invalid user name. -Valid caracters are: underscore '_', '-', 'a' - 'z', 'A' - 'Z', '0' - '9', the single quote ('), the space and the dot. - - + + About + + + About BookAStar + + + Welcome by your stars. + + + Access denied + + + Account Balance + + + Activity + + + Activities + + + additionally + + + Allow my geolocatisation, nearby my clients + + + An instant message has been sent to {0}, showing to him your query. You should be contacted very soon. + + + a prestation + + + Ask for an estimate + + + Attached files + + + You must be authenticated in order to access this information + + + Author + + + available + + + Basket + + + Bill edition + + + Bill removal + + + Bill access control + + + Bill created + + + Bill source code + + + Bill updated + + + body + + + Book an artist + + + Book a performer in information technology + + + Book an artiste + + + Book a software editor + + + Catalog + + + Change user name form + + + Change your account settings + + + Please, choose a description + + + Please, choose a title + + + Please, Choose A Date In The Futur + + + Please, choose a date for this event + + + Ciffer + + + Circles + + + Click action + + + Color + + + Comment + + + Consultant + + + Contact a performer + + + Could not convert '{0}' to double. + + + Count + + + Créer + + + Credits + + + Date search + + + Data base + + + Description + + + Disable + + + Display Name + + + Do an estimate + + + Commenter + + + Une erreur est survenue à la génération de votre document + + + Ne pas publier mon activité + + + Do post + + + S'il vous plait, spécifiez ceux de vos cercles à qui est destiné ce contenu + + + Tagger + + + This email adress is already used ({0}). + + + This user name is already used ({0}). + + + Edit + + + Edited + + + Edit related skills + + + Date de fin + + + Heure de fin + + + e-mail + + + Generated e-mail from {0}, because of your perfomer profile publication, and your email usage agreement. Visit {1} to modify your profile, unsubscribe or unregister. + + + entries + + + Estimate not found + + + Estimate wanted + + + Event Web page + + + Existant data base + + + External Logins + + + Please, use a date in the future as starting date. + + + Restricted area + + + from + + + Tell more, below, about your query + + + Google could'nt identify this place + + + Google calendar + + + Google error : {0} + + + Google registration id + + + Home + + + Hide + + + hidden + + + Hide the bill source text + + + I understood + + + Icons made by + + + Image URI + + + Exception at importing + + + Internal Server Error + + + is licensed by + + + Item added to basket + + + Location + + + Login + + + Logout + + + Main activity + + + Manage + + + Site skills + + + Maximal date for the rendez-vous + + + Mainly Exerted Activity code + + + Manage your account + + + Members + + + Your message has been sent. + + + Minimal date for the rendez-vous + + + Modify + + + My estimates + + + Name + + + Needs + + + Need + + + new instrument + + + New display name + + + New display name + + + New Tag + + + A message had been sent, containing a link to follow in order to update your password. + + + no content + + + No skill was informed by any performer for this activity + + + none + + + Non existent user + + + Not Approuved + + + No calendar was associated to this user. + + + Offline + + + Online + + + Only authorized users may contact a performer by mail. + + + Pdf version + + + Performance date + + + Performance place + + + Performers + + + Performer + + + Person + + + Photo + + + Photo updated + + + Please check your email to reset your password. + + + Please confirm your new password + + + Please fill in a body + + + Please, fill in a reason + + + Posted + + + Prefered date + + + prestation + + + Presation location:{0}.\n + + + Preview + comment on preview + + + Profile edition + + + Private circle + + + Provider identifier + + + Provider name + + + Product_reference + + + Read more ... + + + reason + + + Register + + + Registration: unexpected error occured: "{0}". Please forgive for troubles + + + Remember me + + + Remove + + + Reset your password + + + Role + + + role created + + + Role name + + + Save these settings + + + Search + + + Talents/Compétences/Spécialités gérés sur ce site + + + Skill + + + Skills + + + Please, specify a valid latitude + + + Please, specify a valid longitude + + + Specify a latitude + + + Specify a longitude + + + Please, specify a place + + + {0} would want you to establish an estimate concerning {1} + + + Sound + + + Start date + + + The ending date must be later than the starting one. + + + Start hour + + + Submit + + + Submit changes + + + Tag + + + Tag name + + + LaTeX version + + + This site uses cookies + + + ThisPerformer Gives access to his calendar and seems to be available this + + + This performer gives access to his calendar and it appears he should not be available this + + + ThisPerformerDoesntGiveAccessToHisCalendar + + + Title + + + to + + + Two-Factor authentication + + + Unitary_cost + + + Unregister + + + User List + + + User name + + + List of users assuming the role "{0}" + + + This user is not in this role + + + User skills + + + View source + + + was added to the role + + + There was no user in the "{1}" role. You ({0}) was just added as firt user in the "{1}" role. + + + Welcome + + + + {0} has been notified of your query, you should be fast contacted + + + regarding his calendar, {0} should be available for this booking + + + Paramètres musicien (l'instrument) + + + Paramètres Dj (le compte SoundCloud.com) + + + Paramètres formation (les partenaires) + + + Paramètres généraux: une couleur musicale + + + You need to be authenticated in order to contact a performer + + + You're not administrator + + + Your estimates + + + Your activity + + + Your need + + + your query has been transmitted + + + Your skills, your special fields, the scope of your activities + + + You posts + + + Your profile + + + Your message has been sent + + + Hair Length + + + French + + + English + + + This field is required. + + + Passwords must be at least {0} characters. + + + Passwords must have at least one non letter and non digit character. + + + Passwords must have at least one digit ('0'-'9'). + + + Passwords must have at least one uppercase ('A'-'Z'). + + + Passwords and confirmation are not the same. + + + Password confirmation + + + Invalid user name. +Valid caracters are: underscore '_', '-', 'a' - 'z', 'A' - 'Z', '0' - '9', the single quote ('), the space and the dot. + + + An email has been sent to confirm your addresse. + + \ No newline at end of file diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx index b22f2229..68b3b78c 100644 --- a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx +++ b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx @@ -442,11 +442,12 @@ Ce champ est obligatoire. Champ invalide ... Le Mot de passe doit contenir au moins 6 caractères. - Mot de passe doit contenir au moins a caractère spécial (ni un chiffre, ni une lettre). + Mot de passe doit contenir au moins un caractère spécial (ni un chiffre, ni une lettre). Les mots de passe doivent contenir au moins un chiffre ('0' à '9'). Les mots de passe doivent contenir au moins une lettre majuscule ('A' à 'Z'). Le mot de passe et sa confirmation ne sont pas les mêmes. Confirmation du mot de passe - + L'envoi de de courrier pour confirmation de l'adresse e-mail a échoué. + Un courrier a été envoyé pour confirmation de l'adresse e-mail . diff --git a/Yavsc/Views/Account/AccessDenied.cshtml b/Yavsc/Views/Account/AccessDenied.cshtml index f52b5e98..e4b125d9 100644 --- a/Yavsc/Views/Account/AccessDenied.cshtml +++ b/Yavsc/Views/Account/AccessDenied.cshtml @@ -1,6 +1,7 @@ @{ ViewData["Title"] = SR["Forbidden"]; } +

@ViewData["Title"]

L'accès à cette ressource est protégé. diff --git a/Yavsc/Views/Account/AccountCreated.cshtml b/Yavsc/Views/Account/AccountCreated.cshtml new file mode 100644 index 00000000..87ed2518 --- /dev/null +++ b/Yavsc/Views/Account/AccountCreated.cshtml @@ -0,0 +1,8 @@ +@{ + ViewData["Title"] = "Account creation success"; + +} + +

@ViewData["Title"]

+ +Return to home diff --git a/Yavsc/Views/Account/AccountCreated.fr.cshtml b/Yavsc/Views/Account/AccountCreated.fr.cshtml new file mode 100644 index 00000000..9c2a3499 --- /dev/null +++ b/Yavsc/Views/Account/AccountCreated.fr.cshtml @@ -0,0 +1,11 @@ +@{ + ViewData["Title"] = "Succès de la création du compte"; + +} + +

@ViewData["Title"]

+ +Votre compte a été créé. +Vous devrez confirmer votre addresse e-mail. + +Retourner à l'accueil diff --git a/Yavsc/Views/Shared/_Layout.cshtml b/Yavsc/Views/Shared/_Layout.cshtml index 97ed6c6d..d3931595 100755 --- a/Yavsc/Views/Shared/_Layout.cshtml +++ b/Yavsc/Views/Shared/_Layout.cshtml @@ -107,7 +107,7 @@ h6 { @if (ViewData ["Notify"] != null) { foreach (Notification n in ViewData ["Notify"] as IEnumerable) { }