From 7cc293c1210ffddae83ce44eaf12dcd426bfcd80 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Sat, 2 Jan 2016 23:16:22 +0800 Subject: [PATCH] check Issues #1 --- OpenAuth.App/LoginApp.cs | 22 ++++++------- OpenAuth.Mvc/Controllers/LoginController.cs | 8 ++++- OpenAuth.Mvc/Views/Login/Index.cshtml | 34 ++++++++++++--------- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/OpenAuth.App/LoginApp.cs b/OpenAuth.App/LoginApp.cs index 8206a415..b077fe7d 100644 --- a/OpenAuth.App/LoginApp.cs +++ b/OpenAuth.App/LoginApp.cs @@ -1,4 +1,4 @@ -using OpenAuth.Domain.Interface; +using OpenAuth.Domain.Interface; using System; using System.Collections.Generic; using System.Linq; @@ -35,7 +35,7 @@ namespace OpenAuth.App var user = _repository.FindSingle(u => u.Account == userName); if (user == null) { - throw new Exception("ûʺŲ"); + throw new Exception("用户帐号不存在"); } user.CheckPassword(password); @@ -43,32 +43,32 @@ namespace OpenAuth.App { User = user }; - //ûɫ + //用户角色 var userRoleIds = _relevanceRepository.Find(u => u.FirstId == user.Id && u.Key == "UserRole").Select(u => u.SecondId).ToList(); - //ûɫԼ䵽ģID + //用户角色与自己分配到的模块ID var moduleIds = _relevanceRepository.Find( u => (u.FirstId == user.Id && u.Key == "UserModule") || (u.Key == "RoleModule" && userRoleIds.Contains(u.FirstId))).Select(u =>u.SecondId).ToList(); - //ûɫԼ䵽IJ˵ID + //用户角色与自己分配到的菜单ID var elementIds = _relevanceRepository.Find( u => (u.FirstId == user.Id && u.Key == "UserElement") || (u.Key == "RoleElement" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); - //óûӵеģ + //得出最终用户拥有的模块 loginVM.Modules = _moduleRepository.Find(u => moduleIds.Contains(u.Id)).MapToList(); - //ģ˵Ȩ + //模块菜单权限 foreach (var module in loginVM.Modules) { module.Elements = _moduleElementRepository.Find(u => u.ModuleId == module.Id && elementIds.Contains( u.Id)).ToList(); } - //ûɫԼ䵽ԴID + //用户角色与自己分配到的资源ID var resourceIds = _relevanceRepository.Find( u => (u.FirstId == user.Id && u.Key == "UserResource") || @@ -79,7 +79,7 @@ namespace OpenAuth.App } /// - /// ߵ½ + /// 开发者登陆 /// public LoginUserVM LoginByDev() { @@ -87,11 +87,11 @@ namespace OpenAuth.App { User = new User { - Name = "˺" + Name = "开发者账号" } }; loginUser.Modules = _moduleRepository.Find(null).MapToList(); - //ģIJ˵ + //模块包含的菜单 foreach (var module in loginUser.Modules) { module.Elements = _moduleElementRepository.Find(u => u.ModuleId == module.Id).ToList(); diff --git a/OpenAuth.Mvc/Controllers/LoginController.cs b/OpenAuth.Mvc/Controllers/LoginController.cs index afe96676..8fb5ec68 100644 --- a/OpenAuth.Mvc/Controllers/LoginController.cs +++ b/OpenAuth.Mvc/Controllers/LoginController.cs @@ -5,6 +5,7 @@ using System.Web; using System.Web.Mvc; using Infrastructure.Helper; using OpenAuth.App; +using OpenAuth.Mvc.Models; namespace OpenAuth.Mvc.Controllers { @@ -33,7 +34,12 @@ namespace OpenAuth.Mvc.Controllers } catch (Exception e) { - return View(e.Message); + var response = new BjuiResponse + { + statusCode = "300", + message = e.Message + }; + return View(response); } } diff --git a/OpenAuth.Mvc/Views/Login/Index.cshtml b/OpenAuth.Mvc/Views/Login/Index.cshtml index 75cc32f1..c9646f94 100644 --- a/OpenAuth.Mvc/Views/Login/Index.cshtml +++ b/OpenAuth.Mvc/Views/Login/Index.cshtml @@ -1,7 +1,8 @@ - - +@model OpenAuth.Mvc.Models.BjuiResponse + + - + 系统登录 @@ -161,7 +162,7 @@ $.cookie(COOKIE_NAME, null, { path: '/' }); //删除cookie } $("#login_ok").attr("disabled", true).val('登陆中..'); - // window.location.href = '/Home/Index'; /*注意:生产环境时请删除此行*/ + // window.location.href = '/Home/Index'; /*注意:生产环境时请删除此行*/ return true; }); }); @@ -189,33 +190,36 @@
您还在使用老掉牙的IE,请升级您的浏览器到 IE8以上版本 点击升级  强烈建议您更改换浏览器:谷歌 Chrome
- +
+ + + +