public class SteamUserSession : AuthUserSession
{
public UserService UserService { get; set; } //Should be autowired
public long SteamID { get; private set; }
public User CurrentUser { get; private set; }
public Player SteamProfile { get; private set; }
public List<SteamGame> OwnedApps { get; private set; }
public override void OnAuthenticated(
IServiceBase authService,
IAuthSession session,
IOAuthTokens tokens,
Dictionary<string, string> authInfo)
{
base.OnAuthenticated(authService, session, tokens, authInfo);
// access servicestack user server and load properies for session here
CurrentUser = (User)UserService.Get(new GetUser(SteamID));
}
}
问问题
270 次
1 回答
2
AuthUserSession
只是一个从数据存储中持久化和检索的模型,即它不是从 IOC 解析(和自动连接)的服务/过滤器/等或控制器。
您可以改为使用传入的 IOC 从 IOC 检索依赖项authService
,例如:
public override void OnAuthenticated(
IServiceBase authService,
IAuthSession session,
IOAuthTokens tokens,
Dictionary<string, string> authInfo)
{
base.OnAuthenticated(authService, session, tokens, authInfo);
// access servicestack user server and load properies for session here
var userService = authService.TryResolve<UserService>();
CurrentUser = (User)userService.Get(new GetUser(SteamID));
}
于 2013-07-04T04:01:23.643 回答