OpenAuth.Net/OpenAuth.App/LoginApp.cs

49 lines
1.3 KiB
C#
Raw Normal View History

using System.Linq;
using System.Web;
using Infrastructure;
using OpenAuth.App.ViewModel;
2016-07-08 18:51:48 +08:00
using OpenAuth.App.SSO;
using OpenAuth.Domain.Service;
2015-09-22 23:10:00 +08:00
namespace OpenAuth.App
{
public class LoginApp
{
private AuthoriseService _service;
2015-09-22 23:10:00 +08:00
public LoginApp(AuthoriseService service)
2015-09-22 23:10:00 +08:00
{
_service = service;
2015-09-22 23:10:00 +08:00
}
public LoginUserVM GetLoginUser()
2015-12-01 17:30:24 +08:00
{
2016-07-08 18:51:48 +08:00
if (!AuthUtil.CheckLogin())
{
throw new HttpException(401,"未登录");
}
2016-07-08 18:51:48 +08:00
return AuthUtil.GetCurrentUser();
2016-07-08 11:28:38 +08:00
}
public LoginUserVM GetLoginUser(string username)
{
_service.GetUserAccessed(username);
var user = new LoginUserVM
2015-12-01 17:30:24 +08:00
{
User = _service.User,
AccessedOrgs = _service.Orgs,
Modules = _service.Modules.MapToList<ModuleView>(),
Resources = _service.Resources,
2015-12-01 17:30:24 +08:00
};
foreach (var moduleView in user.Modules)
2015-12-04 00:14:55 +08:00
{
2016-07-08 11:28:38 +08:00
moduleView.Elements =
_service.ModuleElements.Where(u => u.ModuleId == moduleView.Id).OrderBy(u => u.Sort).ToList();
2015-12-04 00:14:55 +08:00
}
2015-12-22 11:55:54 +08:00
return user;
2015-09-22 23:10:00 +08:00
}
}
2015-04-25 12:31:01 +08:00
}