增加功能:完善新用户注册功能,删除原有Register相关页面与脚本

This commit is contained in:
Argo-MacBookPro 2018-08-26 17:14:39 +08:00
parent f37e82513a
commit b1234c9978
12 changed files with 152 additions and 371 deletions

View File

@ -58,16 +58,6 @@ namespace Bootstrap.Admin.Controllers
///
/// </summary>
/// <returns></returns>
public ActionResult Register(User p)
{
if (string.IsNullOrEmpty(p.UserName) || string.IsNullOrEmpty(p.Password) || string.IsNullOrEmpty(p.DisplayName) || string.IsNullOrEmpty(p.Description)) return View();
p.UserStatus = 1;
return UserHelper.SaveUser(p) ? (ActionResult)Redirect("~/html/RegResult.html") : View();
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public ActionResult Mobile()
{
return View();

View File

@ -23,5 +23,13 @@ namespace Bootstrap.Admin.Controllers
{
return BootstrapUser.RetrieveUserByUserName(userName) == null && !UserHelper.RetrieveNewUsers().Any(u => u.UserName == userName);
}
[HttpPost]
[AllowAnonymous]
public bool Post([FromBody] User user)
{
var ret = false;
if (string.IsNullOrEmpty(user.UserName) || string.IsNullOrEmpty(user.Password) || string.IsNullOrEmpty(user.DisplayName) || string.IsNullOrEmpty(user.Description)) return ret;
return UserHelper.SaveUser(user);
}
}
}

View File

@ -1,112 +0,0 @@
@{
ViewBag.Title = "注册新用户";
Layout = "~/Views/Shared/_Root.cshtml";
}
@section css {
<link href="~/css/bootstrap.css" rel="stylesheet">
<link href="~/css/bootstrap-theme.css" rel="stylesheet">
<link href="~/css/font-awesome.css" rel="stylesheet" />
<link href="~/css/register.css" rel="stylesheet" />
}
@section javascript {
<script src="~/js/bootstrap.js"></script>
<script src="~/js/longbow.Common.js"></script>
<script src="~/js/jquery.validate.js"></script>
<script src="~/js/messages_zh.js"></script>
<script src="~/js/sweetalert.js"></script>
<script src="~/js/register.js"></script>
}
<div class="container">
<div class="setup-wrapper">
<header><h2>新用户注册</h2></header>
<div class="setup-header">
<ol class="steps">
<li class="current">
<strong class="step">步骤 1:</strong><span>创建一个账号</span>
</li>
<li>
<strong class="step">步骤 2:</strong><span>确认信息</span>
</li>
</ol>
</div>
<form autocomplete="off" id="signup-form" method="post">
<div class="setup-main">
<div class="setup-form-container">
<h3 class="setup-form-title mb-3">
创建您的账号
</h3>
<div class="form-group">
<label for="userName">登陆账号:</label>
<div class="input-group">
<span class="input-group-addon">@@</span>
<input type="text" id="userName" name="userName" class="form-control" placeholder="登陆账号" value="" autofocus maxlength="50" />
</div>
</div>
<div class="form-group">
<label for="displayName">显示名称:</label>
<div class="input-group">
<span class="glyphicon glyphicon-user input-group-addon"></span>
<input type="text" id="displayName" name="displayName" class="form-control" value="" placeholder="显示名称" maxlength="50" />
</div>
</div>
<div class="form-group">
<label for="password">密码:</label>
<div class="input-group">
<span class="glyphicon glyphicon-lock input-group-addon"></span>
<input type="password" id="password" name="password" class="form-control" value="" placeholder="密码" maxlength="50" />
</div>
</div>
<div class="form-group">
<label for="assurePassword">确认密码:</label>
<div class="input-group">
<span class="glyphicon glyphicon-lock input-group-addon"></span>
<input type="password" id="assurePassword" name="assurePassword" class="form-control" value="" placeholder="确认密码" maxlength="50" />
</div>
</div>
<div class="form-group">
<label for="description">申请理由:</label>
<div class="input-group">
<span class="glyphicon glyphicon-certificate input-group-addon"></span>
<textarea id="description" name="description" class="form-control" placeholder="申请理由500字以内" rows="6" maxlength="500"></textarea>
</div>
</div>
<div class="form-group">
<button id="btnAccount" class="btn btn-primary pull-right" type="button">继续</button>
</div> <!-- /.setup-form-container -->
</div>
</div>
<div class="setup-confirm">
<h3>您注册的信息如下:</h3>
<div class="form-group">
<label>登陆账号:</label><span id="loginID" class="form-control-static"></span>
</div>
<div class="form-group">
<label>显示名称:</label><span id="loginName" class="form-control-static"></span>
</div>
<div class="form-group">
<label>申请理由:</label><span id="loginDesc" class="form-control-static"></span>
</div>
<div class="form-group">
<button id="btnPrev" class="btn btn-secondary" type="button">上一步</button>
<button id="btnSubmit" class="btn btn-primary pull-right" type="submit">确认并提交</button>
</div>
</div>
</form>
<div class="setup-secondary">
<div class="setup-info-module">
<h4>欢迎加入本系统</h4>
<ul class="features-list">
<li><strong>Unlimited</strong> 特性一</li>
<li><strong>Unlimited</strong> 特性二</li>
<li><strong>Unlimited</strong> 特性三</li>
<li><strong>Unlimited</strong> 特性四</li>
<li class="list-divider"></li>
<li><i class="glyphicon glyphicon-ok"></i> 优点一</li>
<li><i class="glyphicon glyphicon-ok"></i> 优点二</li>
<li><i class="glyphicon glyphicon-ok"></i> 优点三</li>
<li><i class="glyphicon glyphicon-ok"></i> 优点四</li>
</ul>
</div>
</div>
</div>
</div>

View File

@ -1,30 +1,38 @@
@model ModelBase
<h2 class="form-signin-heading">@Model.Title</h2>
<div class="login-wrap" data-toggle="LgbValidate" data-valid-button="#btnSubmit">
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="fa fa-user input-group-text"></span>
<div class="container">
<form id="login" method="post" class="form-signin">
<h2 class="form-signin-heading">@Model.Title</h2>
<div class="login-wrap" data-toggle="LgbValidate" data-valid-button="button[type='submit']">
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-user"></span>
</div>
</div>
<input type="text" name="userName" class="form-control" placeholder="用户名" data-required-msg="请输入用户名" value="" autofocus data-valid="true" />
</div>
</div>
<input type="text" name="userName" class="form-control" placeholder="用户名" data-required-msg="请输入用户名" value="" autofocus data-valid="true" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="fa fa-lock input-group-text"></span>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-lock"></span>
</div>
</div>
<input type="password" name="password" class="form-control" value="" placeholder="密码" data-required-msg="请输入密码" data-valid="true" />
</div>
</div>
<div class="form-group">
<div class="form-check">
<input id="remember" name="remember" type="checkbox" class="form-check-input" value="true" /><label for="remember" class="form-check-label">记住我</label>
</div>
</div>
<button class="btn btn-lg btn-login btn-block" type="submit">登 陆</button>
<div class="login-footer">
<a href="#" data-method="register">申请账号</a>
<a href="#" data-method="forgot">忘记密码</a>
</div>
<input type="password" name="password" class="form-control" value="" placeholder="密码" data-required-msg="请输入密码" data-valid="true" />
</div>
</div>
<div class="form-group">
<div class="form-check">
<input name="remember" type="checkbox" class="form-check-input" value="true" /><label for="remember" class="form-check-label">记住我</label>
</div>
</div>
<button class="btn btn-lg btn-login btn-block" type="submit">登 陆</button>
<div class="login-footer">
<div class="login-create"><a href="Register">申请账号</a></div>
<div class="login-reset"><a href="#">忘记密码</a></div>
</div>
</form>
</div>

View File

@ -12,26 +12,99 @@
<link href="~/css/bootstrap.min.css" rel="stylesheet">
<link href="~/css/font-awesome.min.css" rel="stylesheet" />
</environment>
<link href="~/css/sweetalert.css" rel="stylesheet" />
<link href="~/css/theme.css" rel="stylesheet" />
@RenderSection("css", false)
@if (!string.IsNullOrEmpty(Model.Theme))
{
<link href="~/css/@Model.Theme" rel="stylesheet" />
}
}
@section javascript {
<environment include="Development">
<script src="~/js/bootstrap.bundle.js"></script>
<script src="~/js/jquery.validate.js"></script>
<script src="~/js/messages_zh.js"></script>
<script src="~/js/sweetalert.js"></script>
</environment>
<environment exclude="Development">
<script src="~/js/bootstrap.bundle.min.js"></script>
<script src="~/js/jquery.validate.min.js"></script>
<script src="~/js/messages_zh.min.js"></script>
<script src="~/js/sweetalert.min.js"></script>
</environment>
<script src="~/js/longbow.Common.js"></script>
<script src="~/js/longbow.validate.js"></script>
<script src="~/js/login.js"></script>
}
<div class="container">
<form id="login" method="post" class="form-signin">
@await Html.PartialAsync("SignIn")
</form>
@await Html.PartialAsync("SignIn")
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content" data-toggle="LgbValidate" data-valid-button="#btnSubmit" data-valid-modal="#dialogNew">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">新用户注册</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="userName">登陆账号:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-user"></span>
</div>
</div>
<input type="text" id="userName" autocomplete="off" class="form-control" placeholder="登陆账号不可为空" value="" maxlength="50" remote="api/New/" data-remote-msg="此用户已存在" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="displayName">显示名称:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-user"></span>
</div>
</div>
<input type="text" id="displayName" class="form-control" value="" placeholder="显示名称不可为空" maxlength="50" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="password">密码:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-lock"></span>
</div>
</div>
<input type="password" id="password" class="form-control" value="" placeholder="密码不可为空" maxlength="50" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="assurePassword">确认密码:</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<span class="fa fa-lock"></span>
</div>
</div>
<input type="password" id="assurePassword" class="form-control" value="" placeholder="确认密码" maxlength="50" equalTo="#password" data-valid="true" />
</div>
</div>
<div class="form-group">
<label for="description">申请理由:</label>
<textarea id="description" class="form-control" placeholder="申请理由500字以内" rows="6" maxlength="500" data-valid="true"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
<i class="fa fa-times"></i>
<span>关闭</span>
</button>
<button type="button" class="btn btn-primary" id="btnSubmit">
<i class="fa fa-save"></i>
<span>提交</span>
</button>
</div>
</div>
</div>
</div>

View File

@ -19,22 +19,14 @@
}
.login-wrap {
margin: 22px 0 0 370px;
margin: 36px 0 0 370px;
width: 280px;
height: 200px;
}
.login-wrap .login-footer {
padding-bottom: 15px;
}
.login-wrap .login-footer .login-create {
float: left;
}
.login-wrap .login-footer .login-reset {
float: right;
}
.login-footer a:last-child {
float: right;
}
.btn-login {
background: #f67a6e;

View File

@ -25,17 +25,9 @@
padding: 20px;
}
.login-wrap .login-footer {
padding-bottom: 15px;
}
.login-wrap .login-footer .login-create {
float: left;
}
.login-wrap .login-footer .login-reset {
float: right;
}
.login-footer a:last-child {
float: right;
}
.btn-login {
background: #f67a6e;

View File

@ -1,174 +0,0 @@
header h2 {
text-align: center;
}
h3 {
margin-bottom: 20px;
}
ol {
display: block;
list-style-type: decimal;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
-webkit-padding-start: 40px;
}
input.is-invalid {
background-repeat: no-repeat;
background-image: url('../images/error.png');
background-position: right 8px center;
}
input.is-valid {
background-repeat: no-repeat;
background-image: url('../images/success.png');
background-position: right 8px center;
}
.setup-wrapper {
margin: 0 auto;
}
form input {
padding-right: 30px !important;
}
.setup-header {
margin: 0 auto;
text-align: left;
}
.setup-main, .setup-confirm {
float: left;
width: 450px;
}
.setup-confirm {
display: none;
}
.setup-confirm h4 {
padding: 6px 0;
}
.setup-main span {
top: 0;
}
.setup-main .input-group {
margin-bottom: 15px;
}
.setup-secondary {
display: inline-block;
float: right;
width: 250px;
margin-top: 70px;
}
.setup-info-module {
margin-bottom: 30px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 3px;
box-shadow: 0 1px 3px rgba(0,0,0,0.075);
}
.setup-info-module h4 {
padding: 15px;
margin-bottom: 15px;
overflow: hidden;
border-bottom: 1px solid #ddd;
margin-top: 0;
background-color: #5cb85c;
color: #000;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.features-list {
padding: 0 15px 15px;
margin: 0;
font-size: 14px;
list-style: none;
}
.features-list li:first-child {
margin-top: 0;
}
.features-list li {
margin-top: 10px;
}
.features-list li strong {
font-weight: 600;
}
.features-list li i {
margin-right: 5px;
color: #60b044;
}
.features-list .list-divider {
margin: 15px -15px;
border-top: 1px solid #eee;
}
.steps {
display: table;
width: 100%;
padding: 0;
margin: 30px auto 0;
overflow: hidden;
list-style: none;
border: 1px solid #ddd;
border-radius: 3px;
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.steps li:first-child {
border-left: 0;
}
.steps li.current {
color: #000;
background-color: #5cb85c;
}
.steps li {
display: table-cell;
width: 50%;
padding: 10px 15px;
color: #ccc;
cursor: default;
background-color: #fafafa;
border-left: 1px solid #ddd;
}
.steps li .step {
display: block;
}
@media (max-width: 767px) {
.steps {
display: inherit;
}
.steps li {
display: inherit;
width: inherit;
}
.setup-secondary {
display: none;
}
.setup-main, .setup-confirm {
float: inherit;
width: inherit;
}
}

View File

@ -1,3 +1,27 @@
$(function () {
$(".container").autoCenter();
$("a[data-method]").on('click', function () {
var $this = $(this);
switch ($this.attr("data-method")) {
case "register":
$("#dialogNew").modal('show');
break;
case "forgot":
break;
}
});
$('#btnSubmit').on('click', function () {
$.bc({
url: 'api/New',
data: { UserName: $('#userName').val(), Password: $('#password').val(), DisplayName: $('#displayName').val(), Description: $('#description').val() },
modal: '#dialogNew',
swal: false,
callback: function (result) {
var title = result ? "提交成功<br/>等待管理员审批" : "提交失败";
swal({ html: true, showConfirmButton: false, showCancelButton: false, timer: 1500, title: title, type: result ? "success" : "error" });
}
});
});
})

View File

@ -189,7 +189,7 @@
},
lgbSwal: function (options) {
if ($.isFunction(swal)) {
swal($.extend({ showConfirmButton: false, showCancelButton: false, timer: 1000, title: '未设置', type: "success" }, options));
swal($.extend({ html: true, showConfirmButton: false, showCancelButton: false, timer: 1000, title: '未设置', type: "success" }, options));
}
},
getUID: function (prefix) {

View File

@ -84,7 +84,6 @@
$('#logoutNoti').text(result.NewUsersCount);
that.resetWidget();
// tasks
// new users
$('#msgHeaderTask').text(result.TasksCount);
$('#msgHeaderTaskBadge').text(result.TasksCount);
var htmlUserTemplate = '<a class="dropdown-item" href="{4}Admin/Tasks?id={3}"><span class="desc">{0}-{2}</span><span class="percent">{1}%</span></span><div class="progress progress-striped"><div class="progress-bar" role="progressbar" aria-valuenow="{1}" aria-valuemin="0" aria-valuemax="100" style="width: {1}%"><span class="sr-only">{1}% 完成</span></div></div></a>';
@ -96,7 +95,7 @@
// new users
$('#msgHeaderUser').text(result.NewUsersCount);
$('#msgHeaderUserBadge').text(result.NewUsersCount);
htmlUserTemplate = '<li><a href="{4}Admin/Notifications"><span class="label label-success"><i class="fa fa-plus"></i></span><div title="{2}" class="content">{1}({0})</div><span class="small italic">{3}</span></a></li>';
htmlUserTemplate = '<a class="dropdown-item" href="{4}Admin/Notifications"><span class="label label-success"><i class="fa fa-plus"></i></span><div title="{2}" class="content">{1}({0})</div><span class="small italic">{3}</span></a>';
html = result.Users.map(function (u) {
return $.format(htmlUserTemplate, u.UserName, u.DisplayName, u.Description, u.Period, $.formatUrl());
}).join('');
@ -123,7 +122,7 @@
// messages
$('#msgHeaderMsg').text(result.MessagesCount);
$('#msgHeaderMsgBadge').text(result.MessagesCount);
htmlUserTemplate = '<li><a href="{6}Admin/Messages?id={0}"><span class="photo"><img alt="avatar" src="{1}"></span><span class="subject"><span class="from">{2}</span><span class="time">{4}</span></span><span class="message" title="{5}">{3}</span></a></li>';
htmlUserTemplate = '<a class="dropdown-item" href="{6}Admin/Messages?id={0}"><span class="photo"><img alt="avatar" src="{1}"></span><span class="subject"><span class="from">{2}</span><span class="time">{4}</span></span><span class="message" title="{5}">{3}</span></a>';
html = result.Messages.map(function (u) {
return $.format(htmlUserTemplate, u.Id, u.FromIcon, u.FromDisplayName, u.Title, u.Period, u.Content, $.formatUrl());
}).join('');

View File

@ -1,19 +0,0 @@
$(function () {
$('#btnAccount').click(function () {
var valid = $('form').valid();
if (valid) {
$('.setup-main').hide();
$('.steps li').toggleClass('current');
$('#loginID').text($('#userName').val());
$('#loginName').text($('#displayName').val());
$('#loginDesc').text($('#description').val());
$('.setup-confirm').show();
}
});
$('#btnPrev').click(function () {
$('.steps li').toggleClass('current');
$('.setup-main').show();
$('.setup-confirm').hide();
});
});