我需要访问我的用户的 UserId,所以我想这可以通过扩展 user.shared 和 AuthenticationService 来完成。我的目标是在客户端访问 UserId(这是一个“Guid”),默认情况下这是不可能的。
@User.shared 我添加了这些行:
/// <summary>
/// Gets the UserId of the user.
/// </summary>
public Guid UserId { get; private set; }
这里是 AuthenticationService 类 - 我需要在这里插入什么才能返回 UserId ?
[EnableClientAccess]
public class AuthenticationService : AuthenticationBase<User>
{
//adapt GetAuthenticatdUser in order to be able to retrieve the UserId @ the client !
protected override User GetAuthenticatedUser(System.Security.Principal.IPrincipal principal)
{
return base.GetAuthenticatedUser(principal);
//what does this line above actually do ?!!?
//INSERT statement which returns the UserId (Guid)
}
}
THX 给你们所有人——在这个话题上已经浪费了至少 1 个小时:-(。