diff --git a/src/Umbraco.Core/Constants-PropertyEditors.cs b/src/Umbraco.Core/Constants-PropertyEditors.cs
index 3c2a8d6752..e423f58c62 100644
--- a/src/Umbraco.Core/Constants-PropertyEditors.cs
+++ b/src/Umbraco.Core/Constants-PropertyEditors.cs
@@ -411,6 +411,11 @@ namespace Umbraco.Core
/// Alias for the XPath DropDownList datatype.
///
public const string XPathDropDownListAlias = "Umbraco.XPathDropDownList";
+
+ ///
+ /// Alias for the email address property editor
+ ///
+ public const string EmailAddressAlias = "Umbraco.EmailAddress";
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/PropertyEditors/EmailValidator.cs b/src/Umbraco.Core/PropertyEditors/EmailValidator.cs
new file mode 100644
index 0000000000..0fb6a227be
--- /dev/null
+++ b/src/Umbraco.Core/PropertyEditors/EmailValidator.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using Umbraco.Core.Models;
+
+namespace Umbraco.Core.PropertyEditors
+{
+ ///
+ /// A validator that validates an email address
+ ///
+ [ValueValidator("Email")]
+ internal sealed class EmailValidator : ManifestValueValidator, IPropertyValidator
+ {
+ public override IEnumerable Validate(object value, string config, PreValueCollection preValues, PropertyEditor editor)
+ {
+ var asString = value.ToString();
+
+ var emailVal = new EmailAddressAttribute();
+
+ if (emailVal.IsValid(asString) == false)
+ {
+ //TODO: localize these!
+ yield return new ValidationResult("Email is invalid", new[] { "value" });
+ }
+ }
+
+ public IEnumerable Validate(object value, PreValueCollection preValues, PropertyEditor editor)
+ {
+ return Validate(value, null, preValues, editor);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Services/ContentTypeService.cs b/src/Umbraco.Core/Services/ContentTypeService.cs
index afd7da9efe..a2f27f58a2 100644
--- a/src/Umbraco.Core/Services/ContentTypeService.cs
+++ b/src/Umbraco.Core/Services/ContentTypeService.cs
@@ -346,36 +346,7 @@ namespace Umbraco.Core.Services
Audit.Add(AuditTypes.Delete, string.Format("Delete ContentTypes performed by user"), userId, -1);
}
}
-
- ///
- /// Gets an object by its Id
- ///
- /// Id of the to retrieve
- ///
- public IMemberType GetMemberType(int id)
- {
- using (var repository = _repositoryFactory.CreateMemberTypeRepository(_uowProvider.GetUnitOfWork()))
- {
- return repository.Get(id);
- }
- }
-
- ///
- /// Gets an object by its Alias
- ///
- /// Alias of the to retrieve
- ///
- public IMemberType GetMemberType(string alias)
- {
- using (var repository = _repositoryFactory.CreateMemberTypeRepository(_uowProvider.GetUnitOfWork()))
- {
- var query = Query.Builder.Where(x => x.Alias == alias);
- var contentTypes = repository.GetByQuery(query);
-
- return contentTypes.FirstOrDefault();
- }
- }
-
+
///
/// Gets an object by its Id
///
diff --git a/src/Umbraco.Core/Services/IContentTypeService.cs b/src/Umbraco.Core/Services/IContentTypeService.cs
index 9f596e465e..9e7c8d53f9 100644
--- a/src/Umbraco.Core/Services/IContentTypeService.cs
+++ b/src/Umbraco.Core/Services/IContentTypeService.cs
@@ -66,21 +66,7 @@ namespace Umbraco.Core.Services
/// Deleting a will delete all the objects based on this
/// Optional Id of the User deleting the ContentTypes
void Delete(IEnumerable contentTypes, int userId = 0);
-
- ///
- /// Gets an object by its Id
- ///
- /// Id of the to retrieve
- ///
- IMemberType GetMemberType(int id);
-
- ///
- /// Gets an object by its Alias
- ///
- /// Alias of the to retrieve
- ///
- IMemberType GetMemberType(string alias);
-
+
///
/// Gets an object by its Id
///
diff --git a/src/Umbraco.Core/Services/IMemberTypeService.cs b/src/Umbraco.Core/Services/IMemberTypeService.cs
index 9c45d83e68..7857e1dda0 100644
--- a/src/Umbraco.Core/Services/IMemberTypeService.cs
+++ b/src/Umbraco.Core/Services/IMemberTypeService.cs
@@ -12,7 +12,18 @@ namespace Umbraco.Core.Services
/// An Enumerable list of objects
IEnumerable GetAllMemberTypes(params int[] ids);
- IMemberType GetMemberType(string alias);
+ ///
+ /// Gets an object by its Id
+ ///
+ /// Id of the to retrieve
+ ///
IMemberType GetMemberType(int id);
+
+ ///
+ /// Gets an object by its Alias
+ ///
+ /// Alias of the to retrieve
+ ///
+ IMemberType GetMemberType(string alias);
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Services/MemberTypeService.cs b/src/Umbraco.Core/Services/MemberTypeService.cs
index cc5eada678..81a231f7c5 100644
--- a/src/Umbraco.Core/Services/MemberTypeService.cs
+++ b/src/Umbraco.Core/Services/MemberTypeService.cs
@@ -37,17 +37,11 @@ namespace Umbraco.Core.Services
}
}
- public IMemberType GetMemberType(string alias)
- {
- using (var repository = _repositoryFactory.CreateMemberTypeRepository(_uowProvider.GetUnitOfWork()))
- {
- var query = Query.Builder.Where(x => x.Alias == alias);
- var memberTypes = repository.GetByQuery(query);
-
- return memberTypes.FirstOrDefault();
- }
- }
-
+ ///
+ /// Gets an object by its Id
+ ///
+ /// Id of the to retrieve
+ ///
public IMemberType GetMemberType(int id)
{
using (var repository = _repositoryFactory.CreateMemberTypeRepository(_uowProvider.GetUnitOfWork()))
@@ -56,5 +50,21 @@ namespace Umbraco.Core.Services
}
}
+ ///
+ /// Gets an object by its Alias
+ ///
+ /// Alias of the to retrieve
+ ///
+ public IMemberType GetMemberType(string alias)
+ {
+ using (var repository = _repositoryFactory.CreateMemberTypeRepository(_uowProvider.GetUnitOfWork()))
+ {
+ var query = Query.Builder.Where(x => x.Alias == alias);
+ var contentTypes = repository.GetByQuery(query);
+
+ return contentTypes.FirstOrDefault();
+ }
+ }
+
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index e59e6d7303..731f7a0a84 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -358,6 +358,7 @@
+
@@ -450,6 +451,7 @@
+
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js
index 4df4b686c8..f9c83d2d52 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js
@@ -12,6 +12,7 @@ function sectionsDirective($timeout, $window, navigationService, sectionResource
scope.maxSections = 7;
scope.overflowingSections = 0;
+ scope.sections = [];
function loadSections(){
sectionResource.getSections()
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valcompare.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valcompare.directive.js
index 5e7f042825..1a36dcc24f 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valcompare.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valcompare.directive.js
@@ -1,8 +1,10 @@
angular.module('umbraco.directives.validation')
.directive('valCompare',function () {
return {
- require: "ngModel",
- link: function(scope, elem, attrs, ctrl) {
+ require: "ngModel",
+ link: function (scope, elem, attrs, ctrl) {
+
+ //TODO: Pretty sure this should be done using a requires ^form in the directive declaration
var otherInput = elem.inheritedData("$formController")[attrs.valCompare];
ctrl.$parsers.push(function(value) {
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valregex.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valregex.directive.js
index bf37d73392..d1103cdbc3 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valregex.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valregex.directive.js
@@ -6,17 +6,36 @@
* NOTE: there's already an ng-pattern but this requires that a regex expression is set, not a regex string
**/
function valRegex() {
+
return {
require: 'ngModel',
restrict: "A",
link: function (scope, elm, attrs, ctrl) {
+ var flags = "";
+ if (attrs.valRegexFlags) {
+ try {
+ flags = scope.$eval(attrs.valRegexFlags);
+ if (!flags) {
+ flags = attrs.valRegexFlags;
+ }
+ }
+ catch (e) {
+ flags = attrs.valRegexFlags;
+ }
+ }
var regex;
try {
- regex = new RegExp(scope.$eval(attrs.valRegex));
+ var resolved = scope.$eval(attrs.valRegex);
+ if (resolved) {
+ regex = new RegExp(resolved, flags);
+ }
+ else {
+ regex = new RegExp(attrs.valRegex, flags);
+ }
}
catch(e) {
- regex = new RegExp(attrs.valRegex);
+ regex = new RegExp(attrs.valRegex, flags);
}
var patternValidator = function (viewValue) {
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js
index 1deb464037..a66c3b549e 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js
@@ -203,7 +203,7 @@ function umbDataFormatter() {
/** formats the display model used to display the member to the model used to save the member */
formatMemberPostData: function(displayModel, action) {
- //this is basically the same as for media but we need to explicitly add the username,email to the save model
+ //this is basically the same as for media but we need to explicitly add the username,email, password to the save model
var saveModel = this.formatMediaPostData(displayModel, action);
var genericTab = _.find(displayModel.tabs, function (item) {
@@ -216,8 +216,17 @@ function umbDataFormatter() {
var propEmail = _.find(genericTab.properties, function (item) {
return item.alias === "_umb_email";
});
+ var propPass = _.find(genericTab.properties, function (item) {
+ return item.alias === "_umb_password";
+ });
saveModel.email = propEmail.value;
saveModel.username = propLogin.value;
+ //NOTE: This would only be set for new members!
+ if (angular.isString(propPass.value)) {
+ // if we are resetting or changing passwords then that data will come from the property editor and
+ // it's value will be an object not just a string.
+ saveModel.password = propPass.value;
+ }
return saveModel;
},
diff --git a/src/Umbraco.Web.UI.Client/src/views/datatype/edit.html b/src/Umbraco.Web.UI.Client/src/views/datatype/edit.html
index 4a10a5efe1..45a86c7a76 100644
--- a/src/Umbraco.Web.UI.Client/src/views/datatype/edit.html
+++ b/src/Umbraco.Web.UI.Client/src/views/datatype/edit.html
@@ -1,7 +1,8 @@