public ViewResult ChangeEmail(ChangeEmail em)
 {
     if (!HttpContext.Request.Cookies.ContainsKey("Logined"))
     {
         return(View("Login"));
     }
     if (ModelState.IsValid)
     {
         if (userDB.IsEmailExist(em.Email, currentUser.UserID))
         {
             ModelState.AddModelError("Email", "This Email already used by other user, try another one");
             return(View());
         }
         else
         {
             currentUser.Email = em.Email;
             userDB.UpdateEmailInDB(currentUser);
             return(View("Profile", currentUser));
         }
     }
     else
     {
         return(View());
     }
 }
        public ActionResult ChangeUserEmail(ChangeEmail changeEmail)
        {
            if (client == null)
            {
                getClient();
            }

            FirebaseResponse getResponse = client.Get(@"Register/" + changeEmail.Username);

            if (getResponse == null)
            {
                return(View("No user"));
            }
            else
            {
                var changeEmailData = getResponse.ResultAs <Register>();

                if (changeEmailData.Password == changeEmail.Password)
                {
                    changeEmailData.Email = changeEmail.Email;
                    FirebaseResponse setResponse = client.Update(@"Register/" + changeEmailData.Username, changeEmailData);
                    return(View());
                }
            }
            return(View());
        }
Beispiel #3
0
        /// <summary>
        /// Changes the email address of a user.
        /// </summary>
        /// <param name="changeEmail">The <see cref="ChangeEmail"/>.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
        /// <returns>Void.</returns>
        public virtual async Task ChangeEmailAsync(ChangeEmail changeEmail, CancellationToken cancellationToken = default)
        {
            if (changeEmail == null)
            {
                throw new ArgumentNullException(nameof(changeEmail));
            }

            var user = await this.UserManager
                       .FindByIdAsync(changeEmail.UserId);

            if (user == null)
            {
                throw new NullReferenceException(nameof(user));
            }

            var result = await this.UserManager
                         .ChangeEmailAsync(user, changeEmail.NewEmailAddress, changeEmail.Token);

            if (!result.Succeeded)
            {
                this.ThrowIdentityExceptions(result.Errors);
            }

            user.EmailConfirmed = false;

            this.DbContext
            .Update(user);

            await this.DbContext
            .SaveChangesAsync(cancellationToken);
        }
Beispiel #4
0
        public virtual async Task <IActionResult> ChangeEmailAsync([FromBody][Required] ChangeEmail <TIdentity> changeEmail, CancellationToken cancellationToken = default)
        {
            await this.IdentityManager
            .ChangeEmailAsync(changeEmail, cancellationToken);

            return(this.Ok());
        }
Beispiel #5
0
        [HttpPost] public ActionResult ChangeMyEmail(ChangeEmail ce)
        {
            User user = Database.Session.Query <User>().Single(u => u.UserName == User.Identity.Name);

            if (user == null)
            {
                return(HttpNotFound());
            }
            if (!user.CheckPassword(ce.UserPassword))
            {
                ModelState.AddModelError("ChangeEmail", "Your password is incorrect");
            }
            if (Database.Session.Query <User>().Any(u => u.Email == ce.NewEmail))
            {
                ModelState.AddModelError("ChangeEmail", "This e-mail using already");
            }
            else if (user.Email == ce.NewEmail)
            {
                ModelState.AddModelError("ChangeEmail", "You have to enter different email to change");
            }
            if (!ModelState.IsValid)
            {
                return(View("~/Areas/Users/Views/Home/ChangeEmail.cshtml", new ChangeEmail()
                {
                    Email = user.Email
                }));
            }
            user.Email = ce.NewEmail;
            Database.Session.Save(user);
            Database.Session.Flush();
            TempData["UserAlert"] = "Email";
            return(RedirectToAction("index"));
        }
Beispiel #6
0
        /// <summary>
        /// Changes the email or password.
        /// </summary>
        /// <param name="currentCredentials">The current credentials.</param>
        /// <param name="cpec">The credentials required for the email change.</param>
        /// <returns></returns>
        public SessionResponse ChangeEmail(NetSuiteCredential currentCredentials, ChangeEmail cpec)
        {
            var svcMgr = _svcPoolMgr.BuildTemporaryServiceManager();

            svcMgr.Credentials = currentCredentials;
            return(svcMgr.ChangeEmail(cpec));
        }
        public ActionResult ChangeEmail(ChangeEmail model)
        {
            if (ModelState.IsValid)
            {
                string          connection  = ConfigurationManager.AppSettings["InternalAPIURL"];
                var             ctx         = Request.GetOwinContext();
                ClaimsPrincipal user        = ctx.Authentication.User;
                string          accessToken = user.Claims.FirstOrDefault(x => x.Type == "AccessToken").Value;
                Guid            userID      = new Guid(user.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value);

                EditUserRequest request = new EditUserRequest(connection, accessToken, userID);
                request.Email    = model.Email;
                request.Password = model.password1;

                EditUserResponse response = request.Send();

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    TempData["Success"] = "You have successfully updated your email. An email has been sent to the new address with instructions on how to verify the address change.";
                    return(RedirectToAction("Index", "Account"));
                }
                else
                {
                    TempData["Errors"] = "There was an error processing your request. Please try again.";
                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }
Beispiel #8
0
        public ActionResult ChangeEmail(ChangeEmail model)
        {
            if (ModelState.IsValid)
            {
                StockwinnersMember member = _db.StockwinnersMembers.Where(m => m.EmailAddress == model.EmailAddressCurrent).FirstOrDefault();

                if (member == null)
                {
                    ViewBag.Message = "No stockwinners member with the email address exists. Either the email address provided is wrong, or the user has signed up via Facebook or Google in which case we can't change their email address";
                }
                else
                {
                    User user = _db.Users.Where(u => u.EmailAddress == model.EmailAddressCurrent).FirstOrDefault();

                    if (user == null)
                    {
                        ViewBag.Message = "No user with the provided email address exists.";
                    }
                    else
                    {
                        member.EmailAddress = model.EmailAddressNew;
                        user.EmailAddress   = model.EmailAddressNew;

                        ViewBag.Message = "The email has successfully been changed. Please instruct the user to use the new email address to login henceforth.";

                        _db.SaveChanges();
                    }
                }
            }

            return(this.View(model));
        }
        public ActionResult ChangeEmail(ChangeEmail changeEmailModel)
        {
            DatabaseController databaseController = new DatabaseController();

            databaseController.ChangeUserEmail(changeEmailModel);

            return(View());
        }
        public Task <Command> Post(ChangeEmail request)
        {
            var command = request.ConvertTo <Domain.Authentication.Users.Commands.ChangeEmail>();

            command.UserId = Profile.UserId;

            return(_bus.Send("domain", command).IsCommand <Command>());
        }
Beispiel #11
0
        //Change email
        public void ChangeEmail()
        {
            Window dlg = new ChangeEmail();

            dlg.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            if (dlg.ShowDialog() == true)
            {
                Properties.Settings.Default.Save();
            }
        }
Beispiel #12
0
        private void ChangeEmailMailBuilder(string callbackUrl, string sendTo, string oldEmail)
        {
            var email = new ChangeEmail
            {
                CallbackUrl = callbackUrl,
                To          = sendTo,
                OldEmail    = oldEmail
            };

            email.Send();
        }
Beispiel #13
0
        public async Task <IActionResult> ChangeEmail([FromBody] ChangeEmail email)
        {
            if (ModelState.IsValid)
            {
                var newEmail = await changeEmailHandler.Handle(email);

                return(new JsonResult(new { value = newEmail.Email }));
            }

            return(Json("Error"));
        }
 /* Take commands as dependencies.
  * This may get awkward once a constructor
  * takes lots of commands... and you may want to consider
  * using a command dispatcher.
  *
  * Good thing is, we get rid of Service classes,
  * which are basically logic dumpsters.
  *
  * Let the controller actions follow an Accept-Delegate-Reply pattern.
  */
 public UsersController(
     GetUsers getUsers,
     ChangeEmail changeEmail,
     ChangeUsername changeUsername,
     IDistributedCache cache
     )
 {
     this.getUsers       = getUsers;
     this.changeEmail    = changeEmail;
     this.changeUsername = changeUsername;
     this.cache          = cache;
 }
        public async Task <IActionResult> ChangeEmail([FromBody] ChangeEmail changeEmail)
        {
            var find = await _context.Users.FindAsync(new Guid(User.Identity.Name));

            var findEmail = await _context.Users.FirstOrDefaultAsync(c => c.Email == changeEmail.NewEmail);

            if (findEmail != null)
            {
                return(BadRequest("Пользователь с такой почтой уже зарегестрирован"));
            }
            find.Email = changeEmail.NewEmail;
            await _context.SaveChangesAsync();

            return(Ok());
        }
Beispiel #16
0
        [SelectedTab("ChangeEmail")][HttpGet] public ActionResult ChangeMyEmail()
        {
            User user = Database.Session.Query <User>().Single(u => u.UserName == User.Identity.Name);

            if (user == null)
            {
                return(HttpNotFound());
            }
            ChangeEmail ce = new ChangeEmail()
            {
                Email = user.Email
            };

            return(View("~/Areas/Users/Views/Home/ChangeEmail.cshtml", ce));
        }
Beispiel #17
0
        public async Task <ActionResult> ChangeEmail(ChangeEmail model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            AppUser userLoggedIn = await _userManager.FindByNameAsync(User.Identity.Name);

            userLoggedIn.Email = model.NewEmail;

            _db.Users.Update(userLoggedIn);
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #18
0
        public async void ResendEmailIfUnverfed()
        {
            string testEmail = "*****@*****.**";

            // arrange
            await using InWordsDataContext context = InWordsDataContextFactory.Create();

            Account account = new Account()
            {
                Email = testEmail, Hash = new byte[255], Role = RoleType.Unverified
            };
            User User = new User()
            {
                Account = account, NickName = "user"
            };

            await context.SaveChangesAsync();

            var mock = new Mock <IEmailTemplateSender>();

            mock.Setup(a => a.SendMailAsync(testEmail, It.IsAny <EmailTemplateBase>()));
            // act
            var registration = new ChangeEmail(context, mock.Object);

            var requestObject = new AuthorizedRequestObject <EmailChangeRequest, EmailChangeReply>(
                new EmailChangeRequest()
            {
                Email = testEmail,
            })
            {
                UserId = account.AccountId
            };

            var test = await registration.HandleRequest(
                new AuthorizedRequestObject <EmailChangeRequest, EmailChangeReply>(
                    new EmailChangeRequest()
            {
                Email = testEmail,
            }))
                       .ConfigureAwait(false);

            // assert
            Assert.Equal(1, context.EmailVerifies.Count());
            mock.Verify(a => a.SendMailAsync(testEmail, It.IsAny <EmailTemplateBase>()), Times.Once());
        }
        public async Task ChangeEmailAsync(string queryStringValue)
        {
            var         body        = queryStringValue;
            var         request     = TestFactory.CreateHttpRequest(body);
            var         option      = Options.Create(_appSettings);
            ChangeEmail changeEmail = new ChangeEmail(option);
            var         response    = await changeEmail.Run(request, logger);

            try
            {
                var result = (OkObjectResult)response;
                Assert.Equal(200, result.StatusCode);
            }
            catch (InvalidCastException)
            {
                //var result = (ResponseContentModel)((BadRequestObjectResult)response).Value;
                //Assert.Equal(409, result.status);
            }
        }
        public async Task <IResponseContent> ChangeEmailAsync(string tenantUid, string origin, string username, string email, string authorization = "")
        {
            var changeEmail = new ChangeEmail
            {
                Email    = email,
                Username = username,
            };

            try
            {
                IRestResponse response = await SubmitPostAsync(URL_CHANGE_EMAIL, origin, changeEmail, authorization);

                return(await AssertResponseContentAsync <ChangeEmailResponseContent>(response));
            }
            catch (Exception ex)
            {
                return(new ChangeEmailResponseContent
                {
                    Exception = ex
                });
            }
        }
        public ActionResult ChangeEmail(ChangeEmail change)
        {
            var dbc = new DbConnectivityModel();

            change.EmailId  = Request["EmailId"];
            change.Password = Request["Password"];
            var  userId = Session["UserId"].ToString();
            bool result = dbc.ValidateEmail(change.EmailId);

            if (result == true)
            {
                bool exist = dbc.CheckPassword(change.Password, userId);
                if (exist == true)
                {
                    bool outcome = dbc.ChangeEmailId(change.EmailId, change.Password, userId);
                    if (outcome == true)
                    {
                        return(RedirectToAction("Account"));
                    }
                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    ViewBag.PasswordMessage = "Invalid Password";
                    return(View());
                }
            }
            else
            {
                ViewBag.EmailMessage = "Email ID already Registered";
                return(View());
            }
        }
Beispiel #22
0
        public async Task <ApiResult> ChangeEmail(ChangeEmail request)
        {
            request.User = _currentUserProvider.GetUser();

            return(await _mediator.Send(request));
        }
Beispiel #23
0
 /// <summary>
 /// Invokes NetSuite's changeEmail(..) method.
 /// </summary>
 /// <param name="cpec">The credentials required for the password/email change.</param>
 /// <returns>Response from the WebService.</returns>
 public virtual SessionResponse ChangeEmail(ChangeEmail cpec)
 {
     return(InvokeService <SessionResponse>(cpec, "changeEmail"));
 }
Beispiel #24
0
        public ActionResult ChangeEmail()
        {
            ChangeEmail cpn = new ChangeEmail();

            return(View(cpn));
        }
Beispiel #25
0
 public ChangeEmailModel(UserManager <IdentityUser> userManager)
 {
     this._User       = userManager.Users.FirstOrDefault();
     this.UserManager = userManager;
     Input            = new ChangeEmail();
 }
Beispiel #26
0
 public async Task <IActionResult> ChangeEmail([FromBody] ChangeEmail command)
 => Json(await _userService.ChangeEmailAsync(UserId, command.Email));
        public virtual async System.Threading.Tasks.Task <SessionResponse> changeEmailAsync(ChangeEmail changeEmail)
        {
            var request = new changeEmailRequest()
            {
                passport        = passport,
                applicationInfo = applicationInfo,
                partnerInfo     = partnerInfo,
                changeEmail     = changeEmail,
            };
            var response = await((NetSuitePortType)this).changeEmailAsync(request);

            return(response.sessionResponse);
        }