mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-08-23 22:11:35 +08:00
增加登陆逻辑,如果开启,只需要去掉basecontroller中的注释就行
This commit is contained in:
parent
afceafb00c
commit
b91156e06b
BIN
InitModule.sql
Normal file
BIN
InitModule.sql
Normal file
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
using System;
|
||||
using Infrastructure.Helper;
|
||||
using OpenAuth.Domain;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
@ -22,9 +22,8 @@ namespace OpenAuth.App
|
||||
throw new Exception("用户帐号不存在");
|
||||
}
|
||||
|
||||
// user.CheckLogin(password);
|
||||
|
||||
|
||||
user.CheckPassword(password);
|
||||
SessionHelper.AddSessionUser(user);
|
||||
}
|
||||
}
|
||||
}
|
22
OpenAuth.Domain/Core/User.cs
Normal file
22
OpenAuth.Domain/Core/User.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenAuth.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
public partial class User
|
||||
{
|
||||
public void CheckPassword(string password)
|
||||
{
|
||||
if (Password != password)
|
||||
{
|
||||
throw new Exception("密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Core\User.cs" />
|
||||
<Compile Include="Interface\IModuleRepository.cs" />
|
||||
<Compile Include="Interface\IOrgRepository.cs" />
|
||||
<Compile Include="Interface\IRepository.cs" />
|
||||
|
@ -21,7 +21,7 @@ using System.Web.Mvc;
|
||||
|
||||
namespace OpenAuth.Mvc
|
||||
{
|
||||
static internal class AutofacExt
|
||||
internal static class AutofacExt
|
||||
{
|
||||
public static void InitAutofac()
|
||||
{
|
||||
|
@ -29,9 +29,9 @@ namespace OpenAuth.Mvc.Controllers
|
||||
base.OnActionExecuting(filterContext);
|
||||
|
||||
//#region 当Session过期自动跳出登录画面
|
||||
//if (SessionHelper.GetSessionUser<LoginViewModel>() == null)
|
||||
//if (SessionHelper.GetSessionUser<User>() == null)
|
||||
//{
|
||||
// Response.Redirect("~/Account/Login");
|
||||
// Response.Redirect("/Login/Index");
|
||||
//}
|
||||
//#endregion
|
||||
}
|
||||
|
@ -26,10 +26,5 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult Login()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
39
OpenAuth.Mvc/Controllers/LoginController.cs
Normal file
39
OpenAuth.Mvc/Controllers/LoginController.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using OpenAuth.App;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class LoginController : Controller
|
||||
{
|
||||
private LoginApp _app;
|
||||
|
||||
public LoginController()
|
||||
{
|
||||
_app = (LoginApp)DependencyResolver.Current.GetService(typeof(LoginApp));
|
||||
}
|
||||
// GET: Login
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Index(string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.Login(username, password);
|
||||
return RedirectToAction("Index", "Home");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return View(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -126,6 +126,7 @@
|
||||
<Compile Include="AutofacExt.cs" />
|
||||
<Compile Include="Controllers\BaseController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\LoginController.cs" />
|
||||
<Compile Include="Controllers\ModuleManagerController.cs" />
|
||||
<Compile Include="Controllers\OrgManagerController.cs" />
|
||||
<Compile Include="Controllers\RoleManagerController.cs" />
|
||||
@ -606,7 +607,7 @@
|
||||
<Content Include="BJUI\themes\fonts\glyphicons-halflings-regular.woff" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Home\Login.cshtml" />
|
||||
<Content Include="Views\Login\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\OrgManager\Index.cshtml" />
|
||||
|
@ -18,7 +18,7 @@
|
||||
<link href="~/BJUI/plugins/niceValidator/jquery.validator.css" rel="stylesheet">
|
||||
<link href="~/BJUI/plugins/bootstrapSelect/bootstrap-select.css" rel="stylesheet">
|
||||
<link href="~/BJUI/themes/css/FA/css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="~/BJUI/plugins/styles/zTreeStyle/zTreeStyle.css" />
|
||||
<link href="~/BJUI/plugins/styles/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
|
||||
<!--[if lte IE 7]>
|
||||
<link href="~/BJUI/themes/css/ie7.css" rel="stylesheet">
|
||||
<![endif]-->
|
||||
|
@ -142,7 +142,7 @@
|
||||
$("#login_form").submit(function () {
|
||||
var issubmit = true;
|
||||
var i_index = 0;
|
||||
$(this).find('.in').each(function (i) {
|
||||
$(this).find('.in').each(function (i) { //检测为空
|
||||
if ($.trim($(this).val()).length == 0) {
|
||||
$(this).css('border', '1px #ff0000 solid');
|
||||
issubmit = false;
|
||||
@ -161,10 +161,8 @@
|
||||
$.cookie(COOKIE_NAME, null, { path: '/' }); //删除cookie
|
||||
}
|
||||
$("#login_ok").attr("disabled", true).val('登陆中..');
|
||||
var password = HMAC_SHA256_MAC($("#j_username").val(), $("#j_password").val());
|
||||
$("#j_password").val(HMAC_SHA256_MAC($("#j_randomKey").val(), password));
|
||||
window.location.href = 'Index'; /*注意:生产环境时请删除此行*/
|
||||
return false;
|
||||
// window.location.href = '/Home/Index'; /*注意:生产环境时请删除此行*/
|
||||
return true;
|
||||
});
|
||||
});
|
||||
function genTimestamp() {
|
||||
@ -207,18 +205,17 @@
|
||||
-->
|
||||
<div class="login_form">
|
||||
<input type="hidden" value="${randomKey }" id="j_randomKey" />
|
||||
<form action="index.html" id="login_form" method="post">
|
||||
<form action="/Login/Index" id="login_form" method="post">
|
||||
<input type="hidden" name="jfinal_token" value="${jfinal_token }" />
|
||||
<div class="form-group">
|
||||
<label for="j_username" class="t">用户名:</label> <input id="j_username" value="" name="username" type="text" class="form-control x319 in" autocomplete="off">
|
||||
<label for="j_username" class="t">用户名:</label>
|
||||
<input id="j_username" value="" name="username" type="text" class="form-control x319 in" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="j_password" class="t">密 码:</label> <input id="j_password" value="" name="passwordhash" type="password" class="form-control x319 in">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="j_captcha" class="t">验证码:</label> <input id="j_captcha" name="j_captcha" type="text" class="form-control x164 in">
|
||||
<img id="captcha_img" alt="点击更换" title="点击更换" src="/BJUI/images/captcha.jpeg" class="m">
|
||||
<label for="j_password" class="t">密 码:</label>
|
||||
<input id="j_password" value="" name="password" type="password" class="form-control x319 in">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="t"></label>
|
||||
<label for="j_remember" class="m"><input id="j_remember" type="checkbox" value="true"> 记住登陆账号!</label>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?PowerDesigner AppLocale="UTF16" ID="{54F96D9D-A534-4ADF-ADAD-ACFE3C42BC44}" Label="" LastModificationDate="1448848483" Name="OpenAuthDB" Objects="247" Symbols="25" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?>
|
||||
<?PowerDesigner AppLocale="UTF16" ID="{54F96D9D-A534-4ADF-ADAD-ACFE3C42BC44}" Label="" LastModificationDate="1448850188" Name="OpenAuthDB" Objects="247" Symbols="25" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?>
|
||||
<!-- do not edit this file -->
|
||||
|
||||
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
|
||||
@ -12,7 +12,7 @@
|
||||
<a:Code>PDM_OA</a:Code>
|
||||
<a:CreationDate>1430102287</a:CreationDate>
|
||||
<a:Creator>yubaolee</a:Creator>
|
||||
<a:ModificationDate>1448847654</a:ModificationDate>
|
||||
<a:ModificationDate>1448850188</a:ModificationDate>
|
||||
<a:Modifier>Administrator</a:Modifier>
|
||||
<a:History>ORG {9C5FE510-8BFA-4205-BF00-FC94E77A24A2}
|
||||
DAT 1430102318
|
||||
@ -205,7 +205,7 @@ GenScriptName6=
|
||||
GenScriptName7=
|
||||
GenScriptName8=
|
||||
GenScriptName9=
|
||||
GenPathName=F:\测试学习\OpenAuth.Net\
|
||||
GenPathName=E:\测试学习\OpenAuth.Net\
|
||||
GenSingleFile=Yes
|
||||
GenODBC=Yes
|
||||
GenCheckModel=No
|
||||
|
Loading…
Reference in New Issue
Block a user