增加用户登陆账号不可重判断

This commit is contained in:
Argo-Lenovo 2016-11-27 14:21:21 +08:00
parent e1eba5705f
commit 1d70530626
5 changed files with 31 additions and 7 deletions

View File

@ -129,14 +129,22 @@
});
that.animate({ marginTop: "+=" + getHeight() });
},
autoValidate: function (options, handler) {
autoValidate: function (rules, messages, handler) {
// validate
var $this = $(this);
if (messages && $.isArray(messages.button)) {
handler = messages;
messages = {};
}
else {
messages = $.extend({}, messages);
}
$this.validate({
validClass: "has-success",
errorClass: "has-error",
ignore: ".ignore",
rules: $.extend({}, options),
rules: $.extend({}, rules),
messages: $.extend({}, messages),
highlight: function (element, errorClass, validClass) {
$(element).parents('.form-group').addClass(errorClass).removeClass(validClass);
},

View File

@ -30,6 +30,11 @@ namespace Bootstrap.Admin.Controllers
[HttpPut]
public bool Put([FromBody]User value)
{
if (value.UserStatus == 9)
{
// vlaidate userName
return UserHelper.RetrieveUsersByName(value.UserName) == null;
}
var ret = false;
var userName = User.Identity.Name;
if (value.UserName == userName && !LgbPrincipal.IsAdmin(userName))
@ -71,9 +76,9 @@ namespace Bootstrap.Admin.Controllers
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public User Get(int id)
public User Get(string userName)
{
return UserHelper.RetrieveUsers().FirstOrDefault(t => t.ID == id);
return UserHelper.RetrieveUsersByName(userName);
}
/// <summary>
///

View File

@ -92,7 +92,14 @@
$('#dataForm').autoValidate({
userName: {
required: true,
maxlength: 50
maxlength: 50,
remote: {
url: "../api/Users/",
type: "PUT",
data: {
UserStatus: 9
}
}
},
password: {
required: true,
@ -106,5 +113,9 @@
required: true,
maxlength: 50
}
}, {
userName: {
remote: "此登陆名称已存在"
}
});
});

View File

@ -40,7 +40,7 @@ namespace Bootstrap.DataAccess
/// </summary>
public string Description { get; set; }
/// <summary>
/// 获得/设置 用户当前状态 0 表示管理员注册用户 1 表示用户自己注册 2 表示管理员批复
/// 获得/设置 用户当前状态 0 表示管理员注册用户 1 表示用户自己注册 2 表示管理员批复 9 表示前台remote validate
/// </summary>
public int UserStatus { get; set; }
/// <summary>

View File

@ -200,7 +200,7 @@ BEGIN
begin
declare @approveTime datetime = null
if @userStatus = 0 set @approveTime = GETDATE()
if(@id = 0)
if(@id = 0 and not exists (select 1 from Users Where UserName = @userName))
Insert Into Users (UserName, [Password], PassSalt, DisplayName, RegisterTime, ApprovedTime, [Description]) values (@userName, @password, @passSalt, @displayName, GETDATE(), @approveTime, @description)
else
Update Users set UserName = @userName, Password = @password, PassSalt = @passSalt, DisplayName = @displayName where ID = @id