重构代码:首页注册新用户接口api/New更改为api/Register
This commit is contained in:
parent
07489ec0bc
commit
96b704620c
|
@ -1,5 +1,4 @@
|
|||
using Bootstrap.DataAccess;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -29,19 +28,6 @@ namespace Bootstrap.Admin.Controllers
|
|||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 登录页面注册新用户提交按钮调用
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public bool Post([FromBody] User user)
|
||||
{
|
||||
var ret = UserHelper.SaveUser(user);
|
||||
if (ret) NotificationHelper.PushMessage(new MessageBody() { Category = "Users", Message = string.Format("{0}-{1}", user.UserName, user.Description) });
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
/// 新用户授权/拒绝接口
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
|
|
@ -20,5 +20,17 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
{
|
||||
return BootstrapUser.RetrieveUserByUserName(userName) == null && !UserHelper.RetrieveNewUsers().Any(u => u.UserName == userName);
|
||||
}
|
||||
/// <summary>
|
||||
/// 登录页面注册新用户提交按钮调用
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public bool Post([FromBody] User user)
|
||||
{
|
||||
var ret = UserHelper.SaveUser(user);
|
||||
if (ret) NotificationHelper.PushMessage(new MessageBody() { Category = "Users", Message = string.Format("{0}-{1}", user.UserName, user.Description) });
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
$('#btnSubmit').on('click', function () {
|
||||
$.bc({
|
||||
url: "api/New",
|
||||
url: "api/Register",
|
||||
data: { UserName: $('#userName').val(), Password: $('#password').val(), DisplayName: $('#displayName').val(), Description: $('#description').val() },
|
||||
modal: '#dialogNew',
|
||||
method: "post",
|
||||
|
|
Loading…
Reference in New Issue