背景:
之前公司內部做了不少系統,但是權限管理都是分開的;一直都想能夠有一套統一管理的權限管理系統;有的時間都是一直在計划,隨着時間的流逝,計划始終沒有實現,也隨着項目的增多而這權限管理也變得版本多樣了;終於最近能夠狠下心來擠出時間來實施這個計划;
計划
多系統統一權限管理(在這里我定義成UPMS);實現多個系統的權限統一配置管理;還有統一登錄接口,來完成最終的權限認證,因為有了統一配置,肯否定就要有同意登陸認證,要不也是空談;
開發環境
OS:win10
IDE:VS2015
DB:mysql
運行環境:iis6以上
framework:net4.5
Begin
首先,先把界面放出來給大家看看;這種都是因人而異的,ui是在網上download的一個后台管理系統模板,另外加上自己的修改而成;還有用到分頁組件,也是開源組件加以修改的,以上所說的后邊全部都會開源出來。
登陸功能目前是采用from認證方式
[HttpPost] public void Login(LoginOnModel collection) { bool isPersistent = true; var obj = loginRepository.GetOne("select * from UserInfo where UserName=@UserName and UserPassword=@Password and IsDel=0;", collection).FirstOrDefault(); if (obj != null) { SetFormAuthentication(isPersistent, obj); //GetCurrentUserPermissions(obj.ID); Response.Redirect("~/Home/Index"); } } private void SetFormAuthentication(bool isPersistent, LoginOnModel user) { #region //////////////////////////////////////////////////////////////////// DateTime utcNow = DateTime.Now; DateTime cookieUtc = isPersistent ? utcNow.AddDays(7) : utcNow.Add(FormsAuthen tication.Timeout); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user. UserName, utcNow, cookieUtc, isPersistent, user.UserName.ToString(), FormsAuthentication.FormsCookiePath); string ticketEncrypted = FormsAuthentication.Encrypt(ticket); if (string.IsNullOrEmpty(ticketEncrypted)) { throw new InvalidOperationException("FormsAuthentication. Encrypt failed."); } HttpCookie httpCookie = new HttpCookie(FormsAuthentication. FormsCookieName, ticketEncrypted) { Domain = FormsAuthentication.CookieDomain, HttpOnly = true, Secure = FormsAuthentication.RequireSSL, Path = FormsAuthentication.FormsCookiePath, }; var name = Uri.EscapeDataString(user.UserName); HttpCookie nameCookie = new HttpCookie("name", name) { Domain = FormsAuthentication.CookieDomain, HttpOnly = true, Secure = FormsAuthentication.RequireSSL, Path = FormsAuthentication.FormsCookiePath, }; //if (isPersistent) { httpCookie.Expires = utcNow.AddDays(7); nameCookie.Expires = utcNow.AddDays(7); } // FormsAuthentication.SetAuthCookie(name, false); HttpContext.Response.Cookies.Add(httpCookie); HttpContext.Response.Cookies.Add(nameCookie); //////////////////////////////////////////////////////////// #endregion //ViewBag.aaa = Request.Cookies[".FA"].Value; }
html
@model Com.Test.UPMS.Web.Areas.Admin.Models.LoginOnModel
@{
Layout = "~/Areas/Admin/Views/Shared/_LayoutLogin.cshtml";
ViewBag.SystemName = "統一用戶權限管理系統";
ViewBag.CompanyName = "公司";
}
<div class="main-content">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="login-container">
<div class="center">
<h1>
<i class="ace-icon fa fa-leaf green"></i>
@*<span class="red">Ace</span>*@
<span class="white" id="id-text2">@ViewBag.SystemName</span>
</h1>
<h4 class="blue" id="id-company-text">© @ViewBag.CompanyName</h4>
</div>
<div class="space-6"></div>
<div class="position-relative">
<div id="login-box" class="login-box visible widget-box no-border">
<div class="widget-body">
<div class="widget-main">
<h4 class="header blue lighter bigger">
<i class="ace-icon fa fa-user green"></i>
登陸
</h4>
<div class="space-6"></div>
@using (Html.BeginForm("Login", "Login", FormMethod.Post))
{
<fieldset>
<label class="block clearfix">
<span class="block input-icon input-icon-right">
<input type="text" class="form-control" name="UserName" placeholder="用戶名" />
<i class="ace-icon fa fa-user"></i>
</span>
</label>
<label class="block clearfix">
<span class="block input-icon input-icon-right">
<input type="password" class="form-control" name="Password" placeholder="密碼" />
<i class="ace-icon fa fa-lock"></i>
</span>
</label>
<div class="space"></div>
<div class="clearfix">
<label class="inline">
<input type="checkbox" class="ace" />
<span class="lbl"> 記住我</span>
</label>
<button type="submit" class="width-35 pull-right btn btn-sm btn-primary">
<i class="ace-icon fa fa-key"></i>
<span class="bigger-110">登陸</span>
</button>
</div>
<div class="space-4"></div>
</fieldset>
}
</div><!-- /.widget-main -->
</div><!-- /.widget-body -->
</div><!-- /.login-box -->
</div><!-- /.position-relative -->
<div class="navbar-fixed-top align-right">
<br />
<a id="btn-login-dark" href="#">Dark</a>
<span class="blue">/</span>
<a id="btn-login-blur" href="#">Blur</a>
<span class="blue">/</span>
<a id="btn-login-light" href="#">Light</a>
</div>
</div>
</div><!-- /.col -->
</div><!-- /.row -->
</div>
UI效果:

其他功能UI
UI效果:







