Beispiel #1
0
        public async Task <ActionResult> RequestPasswordReset(RequestPasswordResetViewModel model)
        {
            // Validates the received email address based on the view model
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Gets the user entity for the specified email address
            Kentico.Membership.User user = UserManager.FindByEmail(model.Email);

            if (user != null)
            {
                // Generates a password reset token for the user
                string token = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                // Prepares the URL of the password reset link (targets the "ResetPassword" action)
                // Fill in the name of your controller
                string resetUrl = Url.Action("ResetPassword", "PasswordReset", new { userId = user.Id, token }, Request.Url.Scheme);

                // Creates and sends the password reset email to the user's address
                await UserManager.SendEmailAsync(user.Id, "Password reset request",
                                                 String.Format("To reset your account's password, click <a href=\"{0}\">here</a>", resetUrl));
            }

            // Displays a view asking the visitor to check their email and click the password reset link
            return(View("CheckYourEmail"));
        }
Beispiel #2
0
 public UserDto UserData(Kentico.Membership.User userInfo)
 {
     if (userInfo != null)
     {
         return(new UserDto()
         {
             userID = userInfo.Id,
             userGUID = userInfo.GUID,
             firstName = userInfo.FirstName,
             lastName = userInfo.LastName,
             middleName = string.Empty,
             enabled = userInfo.Enabled,
             userName = userInfo.Email
         });
     }
     else
     {
         return(new UserDto());
     }
 }