public IActionResult Register([FromBody] AccountSignUpModel model) { if (!ModelState.IsValid) { return(BadRequest(nameof(model))); } // Register User. var response = _authenticationService.Register(model); if (response.IsFaulted) { return(BadRequest(response.Exception)); } return(Ok(response.Result)); }
public async Task <SignUpResponse> Register(AccountSignUpModel model) { var cognito = new AmazonCognitoIdentityProviderClient(_secret.AwsAccessKey, _secret.AwsSecretKey, _region); var request = new SignUpRequest { ClientId = _secret.ClientId, Password = model.Password, Username = model.Username }; var emailAttribute = new AttributeType { Name = "email", Value = model.Email }; request.UserAttributes.Add(emailAttribute); var response = await cognito.SignUpAsync(request); return(response); }
public ActionResult AccountSignUp(AccountSignUpModel model) { var result = _readOnlyRepository.Query <Account>(a => a.EMail == model.EMail); if (result.Any()) { Error("Email account is already registered in this site!!!"); return(View(model)); } var account = Mapper.Map <Account>(model); account.IsArchived = false; account.IsAdmin = false; account.IsBlocked = false; account.SpaceLimit = 2408; account.Password = EncriptacionMD5.Encriptar(model.Password); account.Isconfirmed = false; account.BucketName = string.Format("mdp.{0}", Guid.NewGuid()); //var account = new Account //{ // Name = accountModel.Name, // LastName = accountModel.LastName, // EMail = accountModel.EMail, // IsArchived = false, // IsBlocked = false, // SpaceLimit = 500, // UsedSpace = 0, // Password = EncriptacionMD5.Encriptar(accountModel.Password) //}; //account.AddRole(new Role{Name = "User",IsArchived = false}); var createdAccount = _writeOnlyRepository.Create(account); var token = Convert.ToInt64(Session["userReferralId"]); if (token != 0) { var userReferring = _readOnlyRepository.GetById <Account>(token); userReferring.Referrals.Add(createdAccount); _writeOnlyRepository.Update(userReferring); } var serverFolderPath = Server.MapPath("~/App_Data/UploadedFiles/" + account.EMail); Directory.CreateDirectory(serverFolderPath); var newBucket = new PutBucketRequest { BucketName = account.BucketName }; AWSClient.PutBucket(newBucket); var putFolder = new PutObjectRequest { BucketName = account.BucketName, Key = "Shared/", ContentBody = string.Empty }; AWSClient.PutObject(putFolder); var sharedDirectory = serverFolderPath + "/Shared"; Directory.CreateDirectory(sharedDirectory); //var serverFolderPath = Server.MapPath("~/App_Data/UploadedFiles/" + account.EMail); //Directory.CreateDirectory(serverFolderPath); //var sharedDirectory =serverFolderPath + "/Shared"; //Directory.CreateDirectory(sharedDirectory); if (createdAccount.Files == null) { createdAccount.Files = new List <Domain.File>(); } if (createdAccount.History == null) { createdAccount.History = new List <Actividades>(); } createdAccount.Files.Add(new Domain.File { CreatedDate = DateTime.Now, FileSize = 0, IsArchived = false, IsDirectory = true, Name = "Shared", Url = "", Type = "", ModifiedDate = DateTime.Now }); _writeOnlyRepository.Update(createdAccount); AddActivity("El usuario se registro.", createdAccount); // ESTOOOOOOO #region EnvioCorreoParaNotificacion var fechaActual = DateTime.Now.Date; var pass = result.FirstOrDefault().Id; var data = "" + fechaActual.Day + fechaActual.Month + fechaActual.Year; var tokenConfir = pass + ";" + EncriptacionMD5.Encriptar(data); //var url = "http://minidropbox-1.apphb.com/PasswordReset/PasswordReset"; var url = "http://minidropboxclase.apphb.com/Account/Confirmed"; var emailBody = new StringBuilder("<b>Confirm your account of MiniDropbox</b>"); emailBody.Append("<br/>"); emailBody.Append("<br/>"); emailBody.Append("<b>" + url + "?token=" + tokenConfir + "<b>"); emailBody.Append("<br/>"); emailBody.Append("<br/>"); emailBody.Append("<b>This link is only valid through " + DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + "</b>"); if (MailSender.SendEmail(model.EMail, "Confirm your account of MiniDropbox", emailBody.ToString())) { return(Cancelar()); } Error("E-Mail failed to be sent, please try again!!!"); return(View(model)); #endregion return(Cancelar()); }
public ActionResult AccountSignUp(AccountSignUpModel model) { var result = _readOnlyRepository.Query <Account>(a => a.EMail == model.EMail); if (result.Any()) { Error("Email account is already registered in this site!!!"); return(View(model)); } var account = Mapper.Map <Account>(model); account.IsArchived = false; account.IsAdmin = false; account.IsBlocked = false; account.Password = EncriptacionMD5.Encriptar(model.Password); account.Isconfirmed = false; var createdAccount = _writeOnlyRepository.Create(account); var token = Convert.ToInt64(Session["userReferralId"]); if (token != 0) { var userReferring = _readOnlyRepository.GetById <Account>(token); userReferring.Referrals.Add(createdAccount); _writeOnlyRepository.Update(userReferring); } var serverFolderPath = Server.MapPath("~/App_Data/UploadedFiles/" + account.EMail); Directory.CreateDirectory(serverFolderPath); // ESTOOOOOOO #region EnvioCorreoParaNotificacion var fechaActual = DateTime.Now.Date; var pass = result.FirstOrDefault().Id; var data = "" + fechaActual.Day + fechaActual.Month + fechaActual.Year; var tokenConfir = pass + ";" + EncriptacionMD5.Encriptar(data); //var url = "http://Galeria-1.apphb.com/PasswordReset/PasswordReset"; var url = "http://Galeriaclase.apphb.com/Account/Confirmed"; var emailBody = new StringBuilder("<b>Confirm your account of Galeria</b>"); emailBody.Append("<br/>"); emailBody.Append("<br/>"); emailBody.Append("<b>" + url + "?token=" + tokenConfir + "<b>"); emailBody.Append("<br/>"); emailBody.Append("<br/>"); emailBody.Append("<b>This link is only valid through " + DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + "</b>"); if (MailSender.SendEmail(model.EMail, "Confirm your account of Galeria", emailBody.ToString())) { return(Cancelar()); } Error("E-Mail failed to be sent, please try again!!!"); return(View(model)); #endregion return(Cancelar()); }