diff --git a/src/Server/Coderr.Server.App/Configuration/BaseConfiguration.cs b/src/Server/Coderr.Server.App/Configuration/BaseConfiguration.cs index 242c69e4..53f2335d 100644 --- a/src/Server/Coderr.Server.App/Configuration/BaseConfiguration.cs +++ b/src/Server/Coderr.Server.App/Configuration/BaseConfiguration.cs @@ -9,6 +9,16 @@ namespace codeRR.Server.App.Configuration /// public sealed class BaseConfiguration : IConfigurationSection { + /// + /// allow new users to register accounts. + /// + /// + /// + /// null = not configured = allow. + /// + /// + public bool? AllowRegistrations { get; set; } + /// /// Base URL for the home page, including protocol (http:// or https://) /// @@ -24,10 +34,7 @@ public sealed class BaseConfiguration : IConfigurationSection /// public string SupportEmail { get; set; } - string IConfigurationSection.SectionName - { - get { return "BaseConfig"; } - } + string IConfigurationSection.SectionName => "BaseConfig"; IDictionary IConfigurationSection.ToDictionary() { diff --git a/src/Server/Coderr.Server.Infrastructure/Configuration/ConfigurationCategoryExtensions.cs b/src/Server/Coderr.Server.Infrastructure/Configuration/ConfigurationCategoryExtensions.cs index 8ec558b8..06a9b9f0 100644 --- a/src/Server/Coderr.Server.Infrastructure/Configuration/ConfigurationCategoryExtensions.cs +++ b/src/Server/Coderr.Server.Infrastructure/Configuration/ConfigurationCategoryExtensions.cs @@ -23,14 +23,29 @@ public static void AssignProperties(this IConfigurationSection section, IDiction foreach (var kvp in settings) { var property = type.GetProperty(kvp.Key); - if (property.PropertyType == typeof(Uri)) + var propertyType = property.PropertyType; + if (propertyType == typeof(Uri)) { var value = new Uri(kvp.Value); property.SetValue(section, value); } - else if (!property.PropertyType.IsAssignableFrom(typeof(string))) + else if (!propertyType.IsAssignableFrom(typeof(string))) { - var value = Convert.ChangeType(kvp.Value, property.PropertyType); + var realType = Nullable.GetUnderlyingType(propertyType); + if (realType != null) + { + // we got a nullable type and the string represents + // null, so just assign it. + if (string.IsNullOrEmpty(kvp.Value)) + { + property.SetValue(section, null); + continue; + } + + propertyType = realType; + } + + var value = Convert.ChangeType(kvp.Value, propertyType); property.SetValue(section, value); } else diff --git a/src/Server/Coderr.Server.Web/Areas/Admin/Controllers/HomeController.cs b/src/Server/Coderr.Server.Web/Areas/Admin/Controllers/HomeController.cs index 4a938670..b336e138 100644 --- a/src/Server/Coderr.Server.Web/Areas/Admin/Controllers/HomeController.cs +++ b/src/Server/Coderr.Server.Web/Areas/Admin/Controllers/HomeController.cs @@ -25,9 +25,11 @@ public ActionResult Basics() { model.BaseUrl = config.BaseUrl.ToString(); model.SupportEmail = config.SupportEmail; + model.AllowRegistrations = config.AllowRegistrations != false; } else { + model.AllowRegistrations = true; model.BaseUrl = Request.Url.ToString().Replace("installation/setup/basics/", ""); ViewBag.NextLink = ""; } @@ -42,7 +44,8 @@ public ActionResult Basics(BasicsViewModel model) var settings = new BaseConfiguration { BaseUrl = new Uri(model.BaseUrl), - SupportEmail = model.SupportEmail + SupportEmail = model.SupportEmail, + AllowRegistrations = model.AllowRegistrations }; ConfigurationStore.Instance.Store(settings); return Redirect(Url.GetNextWizardStep()); @@ -54,9 +57,7 @@ public ActionResult Errors() var config = ConfigurationStore.Instance.Load(); if (config != null) { - model.ActivateTracking = config.ActivateTracking; model.ContactEmail = config.ContactEmail; - model.InstallationId = config.InstallationId; } else ViewBag.NextLink = ""; @@ -72,12 +73,9 @@ public ActionResult Errors(ErrorTrackingViewModel model) var settings = new codeRRConfigSection { - ActivateTracking = model.ActivateTracking, ContactEmail = model.ContactEmail, - InstallationId = model.InstallationId }; ConfigurationStore.Instance.Store(settings); - WebApiApplication.ReportTocodeRR = model.ActivateTracking; return Redirect(Url.GetNextWizardStep()); } diff --git a/src/Server/Coderr.Server.Web/Areas/Admin/Models/BasicsViewModel.cs b/src/Server/Coderr.Server.Web/Areas/Admin/Models/BasicsViewModel.cs index 96f36adc..3a1ce375 100644 --- a/src/Server/Coderr.Server.Web/Areas/Admin/Models/BasicsViewModel.cs +++ b/src/Server/Coderr.Server.Web/Areas/Admin/Models/BasicsViewModel.cs @@ -4,10 +4,21 @@ namespace codeRR.Server.Web.Areas.Admin.Models { public class BasicsViewModel { + /// + /// URL to coderr (typically "http://yourHostName/" or "http://somehost/coderr/") + /// [Required, MinLength(4)] public string BaseUrl { get; set; } + /// + /// Email used when codeRR users ask for internal support + /// [Required, EmailAddress] public string SupportEmail { get; set; } + + /// + /// Allow users to register new accounts + /// + public bool AllowRegistrations { get; set; } } } \ No newline at end of file diff --git a/src/Server/Coderr.Server.Web/Areas/Admin/Models/ErrorTrackingViewModel.cs b/src/Server/Coderr.Server.Web/Areas/Admin/Models/ErrorTrackingViewModel.cs index fd776ef3..e1fa7a86 100644 --- a/src/Server/Coderr.Server.Web/Areas/Admin/Models/ErrorTrackingViewModel.cs +++ b/src/Server/Coderr.Server.Web/Areas/Admin/Models/ErrorTrackingViewModel.cs @@ -4,20 +4,7 @@ namespace codeRR.Server.Web.Areas.Admin.Models { public class ErrorTrackingViewModel { - [Display(Name = "Activate tracking")] - public bool ActivateTracking { get; set; } - [Display(Name = "Contact email"), EmailAddress] public string ContactEmail { get; set; } - - /// - /// A fixed identity which identifies this specific installation. You can generate a GUID and then store it. - /// - /// - /// - /// Used to identify the number of installations that have the same issue. - /// - /// - public string InstallationId { get; set; } } } \ No newline at end of file diff --git a/src/Server/Coderr.Server.Web/Areas/Admin/Views/Home/Basics.cshtml b/src/Server/Coderr.Server.Web/Areas/Admin/Views/Home/Basics.cshtml index 6610d987..196bc86d 100644 --- a/src/Server/Coderr.Server.Web/Areas/Admin/Views/Home/Basics.cshtml +++ b/src/Server/Coderr.Server.Web/Areas/Admin/Views/Home/Basics.cshtml @@ -1,30 +1,38 @@ -@model codeRR.Server.Web.Areas.Admin.Models.BasicsViewModel -@{ - ViewBag.Title = "Admin - Basics"; -} -
-
- -

Base configuration

-
- @Html.ValidationSummary(false) -
- - - Address used when visiting this site. -
-
- - - Used by your users when they need support using codeRR, for instance for account troubles. Also used as sender in outbound emails. -
-
- -
-
-
+@model codeRR.Server.Web.Areas.Admin.Models.BasicsViewModel +@{ + ViewBag.Title = "Admin - Basics"; +} +
+
+

Base configuration

+
+ @Html.ValidationSummary(false) +
+ + + Address used when visiting this site. +
+
+ + + Used by your users when they need support using codeRR, for instance for account troubles. Also used as sender in outbound emails. +
+
+ +
+ Allow users to create new accounts by using the registration page. +
+ +
+ +
+
+
diff --git a/src/Server/Coderr.Server.Web/Areas/Admin/Views/Home/ErrorTracking.cshtml b/src/Server/Coderr.Server.Web/Areas/Admin/Views/Home/ErrorTracking.cshtml index 69bcfa16..93c887e1 100644 --- a/src/Server/Coderr.Server.Web/Areas/Admin/Views/Home/ErrorTracking.cshtml +++ b/src/Server/Coderr.Server.Web/Areas/Admin/Views/Home/ErrorTracking.cshtml @@ -7,29 +7,18 @@

Error tracking

- To correct bugs much faster we would like to activate codeRR for your installation. All exceptions - will be uploaded to our own installation for further analysis. + To correct bugs much faster we use codeRR to track errors in codeRR Community Server. All exceptions + are uploaded to our own installation for further analysis.

@Html.ValidationSummary(false)
- @Html.CheckBoxFor(x => x.ActivateTracking, new {@class = "form-control", style = "display:inline;height:auto;width:inherit;"}) - @Html.LabelFor(x => x.ActivateTracking, new {@class = "control-label"}) -
- Allow us to track errors.
@Html.LabelFor(x => x.ContactEmail, new {@class = "control-label"}) @Html.TextBoxFor(x => x.ContactEmail, new {@class = "form-control", disabled = ""}) Email address that we may contact if we need any further information (will also receive notifications when your errors have been corrected).
-
- @Html.LabelFor(x => x.InstallationId, new {@class = "control-label"}) - @Html.TextBoxFor(x => x.InstallationId, new {@class = "form-control", disabled = ""}) - A fixed identity which identifies this specific installation. You can generate a GUID and then store it. Used to identify the number of installations that have the same issue. -
- A guid generated for your convencience if you want to enable this feature: @Guid.NewGuid().ToString("N") -

diff --git a/src/Server/Coderr.Server.Web/Areas/Admin/Views/Shared/_Layout.cshtml b/src/Server/Coderr.Server.Web/Areas/Admin/Views/Shared/_Layout.cshtml index 55716087..8e33a2b4 100644 --- a/src/Server/Coderr.Server.Web/Areas/Admin/Views/Shared/_Layout.cshtml +++ b/src/Server/Coderr.Server.Web/Areas/Admin/Views/Shared/_Layout.cshtml @@ -53,7 +53,6 @@ @Scripts.Render("~/bundles/jquery") - @Scripts.Render("~/bundles/bootstrap") @RenderSection("scripts", false) \ No newline at end of file diff --git a/src/Server/Coderr.Server.Web/Areas/Installation/Views/Shared/_Layout.cshtml b/src/Server/Coderr.Server.Web/Areas/Installation/Views/Shared/_Layout.cshtml index dc043bf4..8293023d 100644 --- a/src/Server/Coderr.Server.Web/Areas/Installation/Views/Shared/_Layout.cshtml +++ b/src/Server/Coderr.Server.Web/Areas/Installation/Views/Shared/_Layout.cshtml @@ -33,7 +33,6 @@ @Scripts.Render("~/bundles/jquery") -@Scripts.Render("~/bundles/bootstrap") @RenderSection("scripts", false) \ No newline at end of file diff --git a/src/Server/Coderr.Server.Web/Content/Site.css b/src/Server/Coderr.Server.Web/Content/Site.css index edcab2e4..eed1f27a 100644 --- a/src/Server/Coderr.Server.Web/Content/Site.css +++ b/src/Server/Coderr.Server.Web/Content/Site.css @@ -1,4 +1,10 @@ -.ViewContainer { +.validation-summary-errors ul li { + color: red; + list-style-type: none; + margin-left: 0; + padding-left: 0; +} +.ViewContainer { width: 100%; } .morris-hover { diff --git a/src/Server/Coderr.Server.Web/Content/Site.less b/src/Server/Coderr.Server.Web/Content/Site.less index 0a5f4534..31976a72 100644 --- a/src/Server/Coderr.Server.Web/Content/Site.less +++ b/src/Server/Coderr.Server.Web/Content/Site.less @@ -1,4 +1,11 @@ -.ViewContainer { +.validation-summary-errors ul li{ + color: red; + list-style-type: none; + margin-left: 0; + padding-left: 0; +} + +.ViewContainer { width: 100%; } .morris-hover { diff --git a/src/Server/Coderr.Server.Web/Content/Site.min.css b/src/Server/Coderr.Server.Web/Content/Site.min.css index 515b21cb..b207d8fc 100644 --- a/src/Server/Coderr.Server.Web/Content/Site.min.css +++ b/src/Server/Coderr.Server.Web/Content/Site.min.css @@ -1 +1 @@ -.ViewContainer{width:100%;}.morris-hover{position:absolute;z-index:100;}.morris-hover.morris-default-style{border-radius:10px;padding:6px;color:#666;background:rgba(255,255,255,.8);border:solid 2px rgba(230,230,230,.8);font-family:sans-serif;font-size:12px;text-align:center;}.morris-hover.morris-default-style .morris-hover-row-label{font-weight:bold;margin:.25em 0;}.morris-hover.morris-default-style .morris-hover-point{white-space:nowrap;margin:.1em 0;}#pageMenu{display:inline-block;margin-left:10px;} \ No newline at end of file +.validation-summary-errors ul li{color:#f00;list-style-type:none;margin-left:0;padding-left:0;}.ViewContainer{width:100%;}.morris-hover{position:absolute;z-index:100;}.morris-hover.morris-default-style{border-radius:10px;padding:6px;color:#666;background:rgba(255,255,255,.8);border:solid 2px rgba(230,230,230,.8);font-family:sans-serif;font-size:12px;text-align:center;}.morris-hover.morris-default-style .morris-hover-row-label{font-weight:bold;margin:.25em 0;}.morris-hover.morris-default-style .morris-hover-point{white-space:nowrap;margin:.1em 0;}#pageMenu{display:inline-block;margin-left:10px;} \ No newline at end of file diff --git a/src/Server/Coderr.Server.Web/Controllers/AccountController.cs b/src/Server/Coderr.Server.Web/Controllers/AccountController.cs index c6cff753..bd3b8d56 100644 --- a/src/Server/Coderr.Server.Web/Controllers/AccountController.cs +++ b/src/Server/Coderr.Server.Web/Controllers/AccountController.cs @@ -151,16 +151,25 @@ public ActionResult Index() public ActionResult Login() { + var config = ConfigurationStore.Instance.Load(); + var model = new LoginViewModel + { + AllowRegistrations = config.AllowRegistrations != false + }; + var url = ConfigurationManager.AppSettings["LoginUrl"]; if (url != null && url != Request.Url.AbsolutePath) return Redirect(url); - return View(); + return View(model); } [HttpPost] public async Task Login(LoginViewModel model) { + var config = ConfigurationStore.Instance.Load(); + model.AllowRegistrations = config.AllowRegistrations != false; + if (!ModelState.IsValid) return View(model); @@ -228,6 +237,12 @@ public ActionResult Register() [HttpPost] public async Task Register(RegisterViewModel model) { + var config = ConfigurationStore.Instance.Load(); + if (config.AllowRegistrations == false) + { + ModelState.AddModelError("", "New registrations are not allowed."); + } + if (!ModelState.IsValid) return View(model); diff --git a/src/Server/Coderr.Server.Web/Global.asax.cs b/src/Server/Coderr.Server.Web/Global.asax.cs index 88091a2f..cf415cad 100644 --- a/src/Server/Coderr.Server.Web/Global.asax.cs +++ b/src/Server/Coderr.Server.Web/Global.asax.cs @@ -17,7 +17,6 @@ namespace codeRR.Server.Web public class WebApiApplication : HttpApplication { private static readonly ILog _logger; - public static bool ReportTocodeRR; static WebApiApplication() { @@ -50,9 +49,6 @@ private void Application_Error(object sender, EventArgs e) } _logger.Error("Request + " + Request.Url + ", data" + data, exception); - if (!ReportTocodeRR) - return; - var properties = new Dictionary { {"Url", Request.Url.ToString()}, diff --git a/src/Server/Coderr.Server.Web/Infrastructure/Logging/WebApiLogger.cs b/src/Server/Coderr.Server.Web/Infrastructure/Logging/WebApiLogger.cs index 1c146fe6..0084db7a 100644 --- a/src/Server/Coderr.Server.Web/Infrastructure/Logging/WebApiLogger.cs +++ b/src/Server/Coderr.Server.Web/Infrastructure/Logging/WebApiLogger.cs @@ -23,9 +23,6 @@ public override void Log(ExceptionLoggerContext context) _logger.Error("Request + " + context.Request.RequestUri + ", data" + data, context.Exception); _logger.Error(context.Exception); - if (!WebApiApplication.ReportTocodeRR) - return; - var properties = new Dictionary { {"Url", context.Request.RequestUri.ToString()}, diff --git a/src/Server/Coderr.Server.Web/Models/Account/LoginViewmodel.cs b/src/Server/Coderr.Server.Web/Models/Account/LoginViewmodel.cs index cd057af4..205ee375 100644 --- a/src/Server/Coderr.Server.Web/Models/Account/LoginViewmodel.cs +++ b/src/Server/Coderr.Server.Web/Models/Account/LoginViewmodel.cs @@ -11,5 +11,10 @@ public class LoginViewModel [Required] public string UserName { get; set; } + + /// + /// Allow new users to register. + /// + public bool AllowRegistrations { get; set; } } } \ No newline at end of file diff --git a/src/Server/Coderr.Server.Web/Startup.cs b/src/Server/Coderr.Server.Web/Startup.cs index b441adb2..610e6a22 100644 --- a/src/Server/Coderr.Server.Web/Startup.cs +++ b/src/Server/Coderr.Server.Web/Startup.cs @@ -76,7 +76,7 @@ private static void ConfigureApiKeyAuthentication(HttpFilterCollection configFil if (!string.IsNullOrEmpty(configType)) { var instance = TypeHelper.CreateAssemblyObject(configType); - configFilters.Add((IFilter) instance); + configFilters.Add((IFilter)instance); return; } @@ -119,7 +119,7 @@ private void ConfigureConnectionFactory() { var typeName = ConfigurationManager.AppSettings["ConnectionFactoryType"]; if (typeName != null) - ConnectionFactory = (IConnectionFactory) TypeHelper.CreateAssemblyObject(typeName); + ConnectionFactory = (IConnectionFactory)TypeHelper.CreateAssemblyObject(typeName); else ConnectionFactory = new Net452ConnectionFactory(); } @@ -142,10 +142,9 @@ private static void ConfigureErrorTracking() Err.Configuration.ContextProviders.Add(new CustomerInfoProvider( errorTrackingConfig.ContactEmail, errorTrackingConfig.InstallationId)); - Err.Configuration.Credentials(uri, + Err.Configuration.Credentials(uri, "2b3002d3ab3e4a57ad45cff2210221ab", "f381a5c9797f49bd8a3238b892d02806"); - WebApiApplication.ReportTocodeRR = true; GlobalConfiguration.Configuration.Services.Add(typeof(IExceptionLogger), new WebApiLogger()); } else @@ -189,7 +188,7 @@ private static void LoadCustomAuthenticationMiddleware(IAppBuilder app) var middlewareRegistrar = TypeHelper.CreateAssemblyObject(middlewareTypeStr); if (middlewareRegistrar != null) - middlewareRegistrar.GetType().GetMethod("Register").Invoke(middlewareRegistrar, new object[] {app}); + middlewareRegistrar.GetType().GetMethod("Register").Invoke(middlewareRegistrar, new object[] { app }); } } } \ No newline at end of file diff --git a/src/Server/Coderr.Server.Web/Views/Account/Login.cshtml b/src/Server/Coderr.Server.Web/Views/Account/Login.cshtml index c6ae38cf..d2326b56 100644 --- a/src/Server/Coderr.Server.Web/Views/Account/Login.cshtml +++ b/src/Server/Coderr.Server.Web/Views/Account/Login.cshtml @@ -37,7 +37,10 @@
Reset password - @Html.ActionLink("Register", "Register", null, new { @class = "btn" }) + @if (Model.AllowRegistrations) + { + @Html.ActionLink("Register", "Register", null, new { @class = "btn" }) + }
diff --git a/src/Server/Coderr.Server.Web/Views/Account/Register.cshtml b/src/Server/Coderr.Server.Web/Views/Account/Register.cshtml index 6f9a961d..61776c8b 100644 --- a/src/Server/Coderr.Server.Web/Views/Account/Register.cshtml +++ b/src/Server/Coderr.Server.Web/Views/Account/Register.cshtml @@ -9,7 +9,7 @@ -
+