Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Created March 8, 2013 16:54
Show Gist options
  • Save jmarnold/5117936 to your computer and use it in GitHub Desktop.
Save jmarnold/5117936 to your computer and use it in GitHub Desktop.
public class OurWindowsPrincipalHandler : IWindowsPrincipalHandler
{
private readonly ITransaction _transaction;
public OurWindowsPrincipalHandler(ITransaction transaction)
{
_transaction = transaction;
}
public bool Authenticated(IPrincipal principal)
{
_transaction.WithRepository(repository =>
{
if (repository.All<User>().Any(x => x.UserName == principal.Identity.Name)) return;
repository.Update(new User { UserName = principal.Identity.Name });
});
return true;
}
}
ReplaceService<IWindowsPrincipalHandler, OurWindowsPrincipalHandler>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment