Eticaret2014.Models.AspNetUser user = db.AspNetUsers.FirstOrDefault(a => userID == a.Id && a.SifreSifirlama == sifirlamaSifresi); var until = DateTime.Now.AddDays(1); if (null != user) { var token = new StringBuilder(); //Prepare a 10-character random text using (RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider()) { var data = new byte[4]; for (int i = 0; i < 10; i++) { //filled with an array of random numbers rngCsp.GetBytes(data); //this is converted into a character from A to Z var randomchar = Convert.ToChar( //produce a random number //between 0 and 25 BitConverter.ToUInt32(data, 0) % 26 //Convert.ToInt32('A')==65 + 65 ); token.Append(randomchar); } } //This will be the password change identifier //that the user will be sent out var tokenid = token.ToString(); //Generating a token var result = await IdentityManager .Passwords .GenerateResetPasswordTokenAsync( tokenid, user.UserName, until ); if (result.Success) { string gizliParola = Membership.GeneratePassword(8, 0); gizliParola = Regex.Replace(gizliParola, @"[^a-zA-Z0-9]", m => "9").ToLower(); var sonuc = await IdentityManager.Passwords.ResetPasswordAsync(tokenid, gizliParola); if (sonuc.Success) { MailController.SifreGonder(user.UserName, "tr", gizliParola); TempData["HataMesaj"] = "Şifre sıfırlama maili adresinize gönderildi. Lütfen mailinizi kontrol ediniz."; } else { TempData["HataMesaj"] = sonuc.Errors; } } } return View();
asp.net mvc reset password not current password