public UserCreateResponse Register([FromBody] UserCreateRequest userCreateRequest) { try { var user = _userService.Create( userCreateRequest.EmailAddress, userCreateRequest.Password, userCreateRequest.UserData); var tokenValue = (user.Id + StringHelper.RandomString(10, "$*#+%") + DateTime.Now.ToString("O")).Sha1(); var token = _tokenService.Create (TokenTypes.ConfirmRegistration, tokenValue, user.Id, userCreateRequest.TtlSeconds); var confirmRegistrationUrl = _baseApplicationPath + userCreateRequest.ConfirmRegistrationUrl.Replace("{{token}}", token.Value); _mailer.SendMailUsingTemplateAsync ( new Dictionary <string, string> { { userCreateRequest.EmailAddress, userCreateRequest.EmailAddress } }, "Confirm Registration", "ConfirmRegistration", new Dictionary <string, string> { { "confirmRegistrationUrl", confirmRegistrationUrl } }); return(new UserCreateResponse { Id = user.Id }); } catch (Exception ex) { return(new UserCreateResponse { Success = false, Message = ex.Message }); } }