diff --git a/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.controller.js b/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.controller.js index dbec397809..96db5e07b1 100644 --- a/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.controller.js @@ -472,6 +472,7 @@ .then(function (saved) { //success vm.page.createButtonState = "success"; + vm.newUser = saved; setUsersViewState('inviteUserSuccess'); getUsers(); }, function (err) { diff --git a/src/Umbraco.Web/Models/ContentEditing/UserInvite.cs b/src/Umbraco.Web/Models/ContentEditing/UserInvite.cs index 747f64bf7a..06895ccc68 100644 --- a/src/Umbraco.Web/Models/ContentEditing/UserInvite.cs +++ b/src/Umbraco.Web/Models/ContentEditing/UserInvite.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; namespace Umbraco.Web.Models.ContentEditing @@ -8,7 +9,7 @@ namespace Umbraco.Web.Models.ContentEditing /// Represents the data used to invite a user /// [DataContract(Name = "user", Namespace = "")] - public class UserInvite : EntityBasic + public class UserInvite : EntityBasic, IValidatableObject { [DataMember(Name = "userGroups")] [Required] @@ -21,6 +22,11 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "message")] public string Message { get; set; } - + + public IEnumerable Validate(ValidationContext validationContext) + { + if (UserGroups.Any() == false) + yield return new ValidationResult("A user must be assigned to at least one group", new[] { "UserGroups" }); + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Models/ContentEditing/UserSave.cs b/src/Umbraco.Web/Models/ContentEditing/UserSave.cs index 30f6bfc420..1b6a76ae99 100644 --- a/src/Umbraco.Web/Models/ContentEditing/UserSave.cs +++ b/src/Umbraco.Web/Models/ContentEditing/UserSave.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; namespace Umbraco.Web.Models.ContentEditing @@ -47,11 +48,8 @@ namespace Umbraco.Web.Models.ContentEditing public IEnumerable Validate(ValidationContext validationContext) { - //TODO: Add other server side validation - //if (CultureInfo.GetCultureInfo(Culture)) - // yield return new ValidationResult("The culture is invalid", new[] { "Culture" }); - - yield break; + if (UserGroups.Any() == false) + yield return new ValidationResult("A user must be assigned to at least one group", new[] { "UserGroups" }); } } } \ No newline at end of file