Created
August 13, 2013 12:16
-
-
Save ritasker/6220529 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 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