Skip to content

Instantly share code, notes, and snippets.

@ritasker
Created August 13, 2013 12:16
Show Gist options
  • Save ritasker/6220529 to your computer and use it in GitHub Desktop.
Save ritasker/6220529 to your computer and use it in GitHub Desktop.
public AuthenticationModule(IMemberRepository memberRepository, ISecurityLogic securityLogic, IEmailService emailService)
{
_memberRepository = memberRepository;
_securityLogic = securityLogic;
_emailService = emailService;
Post["/register"] = args => PostRegister(this.Bind<RegistrationViewModel>());
}
public Negotiator PostRegister(RegistrationViewModel model)
{
string salt = _securityLogic.GenerateSalt(128);
var member = new Member
{
Email = model.Email,
Salt = salt,
Password = _securityLogic.HashPassword(Guid.NewGuid().ToString(), salt)
};
_memberRepository.Add(member);
_emailService
.NewEmail()
.FromTemplate("Registration")
.WithBodyParameters(new[] { member.Id, model.Email })
.Send();
return View["success"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment