public async Task <IHttpActionResult> Post(RegisterUserModel args) { var newUser = _incomingUserMapper.ToIncomingUser(args); if (!_service.Exists(newUser)) { _service.Add(newUser); Guid randomPart = Guid.NewGuid(); var tokenToHash = randomPart.ToString() + newUser.Id.ToString(); _tokenModel.EmailConfirmationToken = _token.GetHashSha256(tokenToHash); var code = _tokenModel.EmailConfirmationToken; newUser.Token = code; _service.AddToken(newUser); var callbackUrl = new Uri(Url.Link("AngularRoute", new { })); await(_emailService).SendAsync(new IdentityMessage { Body = String.Format(MessagesContainer.ConfiramtionMessage + callbackUrl + "#/EmailConfirmed?id={0}&code={1}", newUser.Id, code), Destination = newUser.Email, Subject = "Registration confirmation at WoW" }); return(Ok(_tokenModel)); } return(BadRequest()); }
public bool CheckUserId(ForgotPasswordUserModel checkEmail) { using (var uow = _unitOfWorkFactory.GetUnitOfWork()) { var users = uow.UserRepository.GetAll(); foreach (var user in users) { if (_token.GetHashSha256(user.Id.ToString()) == checkEmail.Id) { checkEmail.Id = user.Id.ToString(); return(true); } } return(false); } //using (var context = new WorldOfWordsDatabaseContext()) //{ // var users = context.Users; // foreach (var user in users) // { // if (_token.GetHashSha256(user.Id.ToString()) == checkEmail.Id) // { // checkEmail.Id = user.Id.ToString(); // return true; // } // } // return false; //} }
private string GenerateEmailConfirmationToken(string id, bool emailConfirm) { string result = ""; if (emailConfirm) { Guid randomPart = Guid.NewGuid(); var tokenToHash = randomPart.ToString() + id; _tokenModel.EmailConfirmationToken = _token.GetHashSha256(tokenToHash); result = _tokenModel.EmailConfirmationToken; } else { _tokenModel.ForgotPasswordToken = _token.GetHashSha256(id); result = _tokenModel.ForgotPasswordToken; } return(result); }
public bool CheckUserId(ForgotPasswordUserModel checkEmail) { using (var uow = _unitOfWorkFactory.GetUnitOfWork()) { var users = uow.UserRepository.GetAll(); foreach (var user in users) { if (_token.GetHashSha256(user.Id.ToString()) == checkEmail.Id) { checkEmail.Id = user.Id.ToString(); return(true); } } return(false); } }
public bool CheckUserId(ForgotPasswordUserModel checkEmail) { using (var context = new WorldOfWordsDatabaseContext()) { var users = context.Users; foreach (var user in users) { if (_token.GetHashSha256(user.Id.ToString()) == checkEmail.Id) { checkEmail.Id = user.Id.ToString(); return(true); } } return(false); } }