mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2026-04-08 01:51:28 +08:00
调整了一下项目框架与前端JS代码
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
namespace OpenAuth.App.DTO
|
||||
{
|
||||
public class LoginRequest
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenAuth.App.DTO
|
||||
{
|
||||
public class LoginResponse : Response
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenAuth.App.DTO
|
||||
{
|
||||
public class MenuForUserRequest
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenAuth.Domain.Model;
|
||||
|
||||
namespace OpenAuth.App.DTO
|
||||
{
|
||||
public class MenuForUserResponse
|
||||
{
|
||||
private IList<Menu> _menus = new List<Menu>();
|
||||
|
||||
public IList<Menu> Menus
|
||||
{
|
||||
get { return _menus; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace OpenAuth.App.DTO
|
||||
{
|
||||
public abstract class Response
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using OpenAuth.App.DTO;
|
||||
using OpenAuth.Domain.Interface;
|
||||
using OpenAuth.Domain.Service;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class LoginApp
|
||||
{
|
||||
private LoginService _loginService;
|
||||
private IUserRepository _repository;
|
||||
|
||||
public LoginApp(LoginService service)
|
||||
public LoginApp(IUserRepository repository)
|
||||
{
|
||||
_loginService = service;
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public LoginResponse Login(LoginRequest request)
|
||||
public void Login(string userName, string password)
|
||||
{
|
||||
var resp = new LoginResponse {UserName = request.UserName};
|
||||
var user = _repository.FindByAccount(userName);
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception("<22>û<EFBFBD><C3BB>ʺŲ<CABA><C5B2><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
|
||||
user.CheckLogin(password);
|
||||
|
||||
LoginCacheApp.SetLogin(user);
|
||||
|
||||
try
|
||||
{
|
||||
var user = _loginService.Login(request.UserName, request.Password);
|
||||
resp.UserId = user.Id;
|
||||
resp.Success = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
resp.Success = false;
|
||||
resp.Message = ex.Message;
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
using System.Web;
|
||||
|
||||
using OpenAuth.App.DTO;
|
||||
using OpenAuth.Domain;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class LoginCacheApp
|
||||
{
|
||||
public static LoginResponse GetLogin()
|
||||
public static User GetLogin()
|
||||
{
|
||||
var session = HttpContext.Current.Session;
|
||||
return session["Login"] as LoginResponse;
|
||||
return session["Login"] as User;
|
||||
}
|
||||
|
||||
public static void SetLogin(LoginResponse loginresp)
|
||||
public static void SetLogin(User loginresp)
|
||||
{
|
||||
var session = HttpContext.Current.Session;
|
||||
var login = session["Login"] as LoginResponse;
|
||||
var login = session["Login"] as User;
|
||||
if (login != null && login.UserId == loginresp.UserId)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : OpenAuth.App
|
||||
// Author : yubaolee
|
||||
// Created : 05-19-2015
|
||||
//
|
||||
// Last Modified By : yubaolee
|
||||
// Last Modified On : 05-20-2015
|
||||
// ***********************************************************************
|
||||
// <copyright file="MenuApp.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// <summary>菜单服务</summary>
|
||||
// ***********************************************************************
|
||||
using System.Collections.Generic;
|
||||
using OpenAuth.App.DTO;
|
||||
using OpenAuth.Domain.Model;
|
||||
using OpenAuth.Domain.Service;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class MenuApp
|
||||
{
|
||||
private MenuService _menuService;
|
||||
|
||||
public MenuApp(MenuService service)
|
||||
{
|
||||
_menuService = service;
|
||||
}
|
||||
public MenuForUserResponse LoadMenus()
|
||||
{
|
||||
var response = new MenuForUserResponse();
|
||||
var user = LoginCacheApp.GetLogin();
|
||||
if (user != null)
|
||||
{
|
||||
// response.Menus =
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,24 +40,18 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DTO\LoginRequest.cs" />
|
||||
<Compile Include="DTO\LoginResponse.cs" />
|
||||
<Compile Include="DTO\MenuForUserRequest.cs" />
|
||||
<Compile Include="DTO\MenuForUserResponse.cs" />
|
||||
<Compile Include="LoginApp.cs" />
|
||||
<Compile Include="LoginCacheApp.cs" />
|
||||
<Compile Include="MenuApp.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="DTO\Response.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenAuth.Domain\OpenAuth.Domain.csproj">
|
||||
<Project>{6108da8e-92a1-4abe-b9f5-26d64d55ca2c}</Project>
|
||||
<Name>OpenAuth.Domain</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\OpenAuth.Infrastructure\OpenAuth.Infrastructure.csproj">
|
||||
<Project>{adae08c0-de22-41f7-9f94-0e62ae327c25}</Project>
|
||||
<Name>OpenAuth.Infrastructure</Name>
|
||||
<ProjectReference Include="..\OpenAuth.Repository\OpenAuth.Repository.csproj">
|
||||
<Project>{e8df8dea-e2cf-4bdb-8f4f-3f8205b0e03a}</Project>
|
||||
<Name>OpenAuth.Repository</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的常规信息通过以下
|
||||
|
||||
Reference in New Issue
Block a user