Skip to content

Instantly share code, notes, and snippets.

@Buthrakaur
Created January 19, 2010 14:41
Show Gist options
  • Save Buthrakaur/280965 to your computer and use it in GitHub Desktop.
Save Buthrakaur/280965 to your computer and use it in GitHub Desktop.
public class WcfApplicationContext: IApplicationContext
{
private readonly IRepository<User> userRepository;
public WcfApplicationContext(IRepository<User> userRepository)
{
this.userRepository = userRepository;
}
public User CurrentUser
{
get
{
var identity = OperationContext.Current.ServiceSecurityContext.PrimaryIdentity;
if (!identity.IsAuthenticated || string.IsNullOrEmpty(identity.Name))
{
return null;
}
return userRepository.Get(x => x.UserName == identity.Name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment