Set password operational
Sitewide plan for status messages
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using AutoMapper;
|
||||
using MileageTraker.Web.Attributes;
|
||||
using MileageTraker.Web.DAL;
|
||||
using MileageTraker.Web.Models;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.User
|
||||
{
|
||||
public class CreateUserViewModel
|
||||
public class CreateUserViewModel : RolesViewModel
|
||||
{
|
||||
[Required]
|
||||
[StringLength(64)]
|
||||
@@ -28,25 +25,13 @@ namespace MileageTraker.Web.ViewModels.User
|
||||
|
||||
[Required, DataType(DataType.Password)]
|
||||
[StringLength(16, MinimumLength = 6)]
|
||||
[InputSize("medium")]
|
||||
public string Password { get; set; }
|
||||
|
||||
public string[] Roles { get; set; }
|
||||
|
||||
public IList<string> AvailableRoles { get; set; }
|
||||
public IList<string> SelectedRoles { get; set; }
|
||||
|
||||
static CreateUserViewModel()
|
||||
{
|
||||
Mapper.CreateMap<CreateUserViewModel, Models.User>();
|
||||
Mapper.CreateMap<string, Role>()
|
||||
.ConvertUsing(
|
||||
roleName =>
|
||||
{
|
||||
using (var ds = new DataService())
|
||||
{
|
||||
return ds.GetRoleByName(roleName);
|
||||
}
|
||||
});
|
||||
Mapper.CreateMap<CreateUserViewModel, Models.User>()
|
||||
.ForMember(vm => vm.Roles, opt => opt.Ignore());
|
||||
}
|
||||
|
||||
public Models.User ToUser()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
using AutoMapper;
|
||||
using MileageTraker.Web.Attributes;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.User
|
||||
{
|
||||
public class EditUserViewModel : RolesViewModel
|
||||
{
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(64)]
|
||||
[InputSize("small")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataType(DataType.EmailAddress)]
|
||||
[RegularExpression(@"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}", ErrorMessage = "Must be an email address")]
|
||||
[InputSize("large")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(128)]
|
||||
[RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Need complete name")]
|
||||
[InputSize("medium")]
|
||||
public string FullName { get; set; }
|
||||
|
||||
static EditUserViewModel()
|
||||
{
|
||||
Mapper.CreateMap<Models.User, EditUserViewModel>()
|
||||
.ForMember(u => u.Roles, opt => opt.Ignore());
|
||||
}
|
||||
|
||||
public EditUserViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public EditUserViewModel(Models.User user)
|
||||
{
|
||||
Mapper.Map(user, this);
|
||||
}
|
||||
|
||||
public void UpdateUser(Models.User user)
|
||||
{
|
||||
user.Username = this.Username;
|
||||
user.FullName = this.FullName;
|
||||
user.Email = this.Email;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.User
|
||||
{
|
||||
public class RolesViewModel
|
||||
{
|
||||
public string[] Roles { get; set; }
|
||||
public IList<string> AvailableRoles { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.User
|
||||
{
|
||||
public class SetPasswordViewModel
|
||||
{
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public string Username { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "New password")]
|
||||
public string NewPassword { get; set; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Confirm new password")]
|
||||
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.User
|
||||
{
|
||||
public class UserDetailsViewModel
|
||||
{
|
||||
public string Username { get; set; }
|
||||
|
||||
public string FirstName { get; set; }
|
||||
|
||||
public string LastName { get; set; }
|
||||
|
||||
public string[] Roles { get; set; }
|
||||
|
||||
[DisplayFormat(DataFormatString = @"{0:MM/dd/yyyy}")]
|
||||
public DateTime LastActivityDate { get; set; }
|
||||
|
||||
[DisplayFormat(DataFormatString = @"{0:MM/dd/yyyy}")]
|
||||
public DateTime CreateDate { get; set; }
|
||||
|
||||
public bool IsLockedOut { get; set; }
|
||||
|
||||
[DisplayFormat(DataFormatString = @"{0:MM/dd/yyyy}")]
|
||||
public DateTime LastLockoutDate { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user