Fixes invite user and setting the model correctly. Fixes server side validation to ensure any created user MUST have a group assigned.
This commit is contained in:
@@ -472,6 +472,7 @@
|
||||
.then(function (saved) {
|
||||
//success
|
||||
vm.page.createButtonState = "success";
|
||||
vm.newUser = saved;
|
||||
setUsersViewState('inviteUserSuccess');
|
||||
getUsers();
|
||||
}, function (err) {
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
[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<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (UserGroups.Any() == false)
|
||||
yield return new ValidationResult("A user must be assigned to at least one group", new[] { "UserGroups" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<ValidationResult> 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" });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user