2016-07-12 12:28:54 +08:00
|
|
|
|
using System.Linq;
|
2016-04-21 10:54:05 +08:00
|
|
|
|
using System.Web;
|
|
|
|
|
using Infrastructure;
|
|
|
|
|
using OpenAuth.App.ViewModel;
|
2016-07-08 18:51:48 +08:00
|
|
|
|
using OpenAuth.App.SSO;
|
2016-04-21 10:54:05 +08:00
|
|
|
|
using OpenAuth.Domain.Service;
|
2015-09-22 23:10:00 +08:00
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App
|
|
|
|
|
{
|
|
|
|
|
public class LoginApp
|
|
|
|
|
{
|
2016-04-21 10:54:05 +08:00
|
|
|
|
private AuthoriseService _service;
|
2015-09-22 23:10:00 +08:00
|
|
|
|
|
2016-04-21 10:54:05 +08:00
|
|
|
|
public LoginApp(AuthoriseService service)
|
2015-09-22 23:10:00 +08:00
|
|
|
|
{
|
2016-04-21 10:54:05 +08:00
|
|
|
|
_service = service;
|
2015-09-22 23:10:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-21 10:54:05 +08:00
|
|
|
|
public LoginUserVM GetLoginUser()
|
2015-12-01 17:30:24 +08:00
|
|
|
|
{
|
2016-07-08 18:51:48 +08:00
|
|
|
|
if (!AuthUtil.CheckLogin())
|
2016-04-21 10:54:05 +08:00
|
|
|
|
{
|
2016-04-25 11:53:21 +08:00
|
|
|
|
throw new HttpException(401,"未登录");
|
2016-04-21 10:54:05 +08:00
|
|
|
|
}
|
2016-07-08 18:51:48 +08:00
|
|
|
|
|
|
|
|
|
return AuthUtil.GetCurrentUser();
|
2016-07-08 11:28:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LoginUserVM GetLoginUser(string username)
|
|
|
|
|
{
|
2016-04-21 10:54:05 +08:00
|
|
|
|
_service.GetUserAccessed(username);
|
|
|
|
|
var user = new LoginUserVM
|
2015-12-01 17:30:24 +08:00
|
|
|
|
{
|
2016-04-21 10:54:05 +08:00
|
|
|
|
User = _service.User,
|
|
|
|
|
AccessedOrgs = _service.Orgs,
|
|
|
|
|
Modules = _service.Modules.MapToList<ModuleView>(),
|
|
|
|
|
Resources = _service.Resources,
|
2015-12-01 17:30:24 +08:00
|
|
|
|
};
|
2016-04-21 10:54:05 +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
|
|
|
|
|
2016-04-21 10:54:05 +08:00
|
|
|
|
return user;
|
2015-09-22 23:10:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-25 12:31:01 +08:00
|
|
|
|
}
|