ApiApp.cs
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Linq;
using WebRepository;
namespace WebApp
{
public class ApiApp
{
protected IUnitWork _unitWork;
protected IAuth _authUtil;
protected BaseDBContext _context;
protected LoginInfo _loginInfo;
public ApiApp(IUnitWork unitWork, IAuth auth, BaseDBContext context)
{
_unitWork = unitWork;
_authUtil = auth;
_context = context;
AuthStrategyContext authStrategyContext = _authUtil.GetCurrentUser();
if (authStrategyContext != null)
{
_loginInfo = new LoginInfo
{
Id = authStrategyContext.User.Id,
Account = authStrategyContext.User.Account,
Name = authStrategyContext.User.Name,
};
}
else
{
_loginInfo = new LoginInfo
{
Id = 0,
Account = "Guest",
Name = "匿名",
};
}
}
public bool CheckLogin()
{
try
{
if (_authUtil.CheckLogin())
{
return true;
}
}
catch (Exception)
{
return false;
}
return false;
}
}
}