增加用户登陆账号不可重判断
This commit is contained in:
parent
e1eba5705f
commit
1d70530626
|
@ -129,14 +129,22 @@
|
||||||
});
|
});
|
||||||
that.animate({ marginTop: "+=" + getHeight() });
|
that.animate({ marginTop: "+=" + getHeight() });
|
||||||
},
|
},
|
||||||
autoValidate: function (options, handler) {
|
autoValidate: function (rules, messages, handler) {
|
||||||
// validate
|
// validate
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
|
if (messages && $.isArray(messages.button)) {
|
||||||
|
handler = messages;
|
||||||
|
messages = {};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
messages = $.extend({}, messages);
|
||||||
|
}
|
||||||
$this.validate({
|
$this.validate({
|
||||||
validClass: "has-success",
|
validClass: "has-success",
|
||||||
errorClass: "has-error",
|
errorClass: "has-error",
|
||||||
ignore: ".ignore",
|
ignore: ".ignore",
|
||||||
rules: $.extend({}, options),
|
rules: $.extend({}, rules),
|
||||||
|
messages: $.extend({}, messages),
|
||||||
highlight: function (element, errorClass, validClass) {
|
highlight: function (element, errorClass, validClass) {
|
||||||
$(element).parents('.form-group').addClass(errorClass).removeClass(validClass);
|
$(element).parents('.form-group').addClass(errorClass).removeClass(validClass);
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,6 +30,11 @@ namespace Bootstrap.Admin.Controllers
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
public bool Put([FromBody]User value)
|
public bool Put([FromBody]User value)
|
||||||
{
|
{
|
||||||
|
if (value.UserStatus == 9)
|
||||||
|
{
|
||||||
|
// vlaidate userName
|
||||||
|
return UserHelper.RetrieveUsersByName(value.UserName) == null;
|
||||||
|
}
|
||||||
var ret = false;
|
var ret = false;
|
||||||
var userName = User.Identity.Name;
|
var userName = User.Identity.Name;
|
||||||
if (value.UserName == userName && !LgbPrincipal.IsAdmin(userName))
|
if (value.UserName == userName && !LgbPrincipal.IsAdmin(userName))
|
||||||
|
@ -71,9 +76,9 @@ namespace Bootstrap.Admin.Controllers
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public User Get(int id)
|
public User Get(string userName)
|
||||||
{
|
{
|
||||||
return UserHelper.RetrieveUsers().FirstOrDefault(t => t.ID == id);
|
return UserHelper.RetrieveUsersByName(userName);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
|
@ -92,7 +92,14 @@
|
||||||
$('#dataForm').autoValidate({
|
$('#dataForm').autoValidate({
|
||||||
userName: {
|
userName: {
|
||||||
required: true,
|
required: true,
|
||||||
maxlength: 50
|
maxlength: 50,
|
||||||
|
remote: {
|
||||||
|
url: "../api/Users/",
|
||||||
|
type: "PUT",
|
||||||
|
data: {
|
||||||
|
UserStatus: 9
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -106,5 +113,9 @@
|
||||||
required: true,
|
required: true,
|
||||||
maxlength: 50
|
maxlength: 50
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
userName: {
|
||||||
|
remote: "此登陆名称已存在"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -40,7 +40,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 用户当前状态 0 表示管理员注册用户 1 表示用户自己注册 2 表示管理员批复
|
/// 获得/设置 用户当前状态 0 表示管理员注册用户 1 表示用户自己注册 2 表示管理员批复 9 表示前台remote validate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int UserStatus { get; set; }
|
public int UserStatus { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -200,7 +200,7 @@ BEGIN
|
||||||
begin
|
begin
|
||||||
declare @approveTime datetime = null
|
declare @approveTime datetime = null
|
||||||
if @userStatus = 0 set @approveTime = GETDATE()
|
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)
|
Insert Into Users (UserName, [Password], PassSalt, DisplayName, RegisterTime, ApprovedTime, [Description]) values (@userName, @password, @passSalt, @displayName, GETDATE(), @approveTime, @description)
|
||||||
else
|
else
|
||||||
Update Users set UserName = @userName, Password = @password, PassSalt = @passSalt, DisplayName = @displayName where ID = @id
|
Update Users set UserName = @userName, Password = @password, PassSalt = @passSalt, DisplayName = @displayName where ID = @id
|
||||||
|
|
Loading…
Reference in New Issue