Created
November 28, 2014 02:59
-
-
Save EfrainReyes/a220a77fd48c0c6b7ac0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CurrentUser : ICurrentUser { | |
private readonly IIdentity _identity; | |
private readonly HttpSessionStateBase _session; | |
private readonly UserInfoService _service; | |
private IUserInfo _user; | |
public CurrentUser(IIdentity identity, HttpSessionStateBase session, UserInfoService service) { | |
_identity = identity; | |
_session = session; | |
_service = service; | |
} | |
public IUserInfo User { | |
get { | |
if (_user != null) return _user; | |
_user = _session["UserInfo"] as IUserInfo; | |
if (_user != null) return _user; | |
_user = _identity != null && !string.IsNullOrEmpty(_identity.Name) | |
? _service.GetUserByName(_identity.Name) | |
: null; | |
_session["UserInfo"] = _user; | |
return _user; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment