2015-05-22 17:45:18 +08:00
|
|
|
|
using System;
|
2015-04-25 12:31:01 +08:00
|
|
|
|
using OpenAuth.Domain.Interface;
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App
|
|
|
|
|
{
|
|
|
|
|
public class LoginApp
|
|
|
|
|
{
|
2015-09-20 21:59:36 +08:00
|
|
|
|
private IUserRepository _repository;
|
2015-04-25 12:31:01 +08:00
|
|
|
|
|
2015-09-20 21:59:36 +08:00
|
|
|
|
public LoginApp(IUserRepository repository)
|
2015-04-25 12:31:01 +08:00
|
|
|
|
{
|
2015-09-20 21:59:36 +08:00
|
|
|
|
_repository = repository;
|
2015-04-25 12:31:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-20 21:59:36 +08:00
|
|
|
|
public void Login(string userName, string password)
|
2015-04-25 12:31:01 +08:00
|
|
|
|
{
|
2015-09-20 21:59:36 +08:00
|
|
|
|
var user = _repository.FindByAccount(userName);
|
|
|
|
|
if (user == null)
|
2015-04-25 12:31:01 +08:00
|
|
|
|
{
|
2015-09-20 21:59:36 +08:00
|
|
|
|
throw new Exception("<22>û<EFBFBD><C3BB>ʺŲ<CABA><C5B2><EFBFBD><EFBFBD><EFBFBD>");
|
2015-04-25 12:31:01 +08:00
|
|
|
|
}
|
2015-09-20 21:59:36 +08:00
|
|
|
|
|
|
|
|
|
user.CheckLogin(password);
|
|
|
|
|
|
|
|
|
|
LoginCacheApp.SetLogin(user);
|
|
|
|
|
|
2015-04-25 12:31:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|