public async Task <IHttpActionResult> ChangePasswordEmail(ChangePasswordBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } SUser suser = new SUser(); var user = suser.GetUserByEmail(model.Email); if (AppUserManager.VerifyUserToken(user.Id, DateTime.Today.ToShortDateString(), model.Token.Replace("#ChangePassword", ""))) { string settok = UserManager.GeneratePasswordResetToken(user.Id); IdentityResult result = UserManager.ResetPassword(user.Id, settok, model.NewPassword); return(Json(new { success = true, issue = model.Email, errors = "", tipo = model.Email, UserEmail = model.Email, Url = Url.Content("/Freelance/Logout").ToString() })); if (!result.Succeeded) { return(GetErrorResult(result)); } } else { return(Json(new { success = false, issue = model.Email, errors = "", tipo = model.Email, UserEmail = model.Email, Url = Url.Content("/Freelance/Logout").ToString() })); } }
public ActionResult Index(string email) { //if (SessionBag.Current.Logout == true && SessionBag.Current.Logout!=null) // return Redirect(Url.Content("~/Static/index.html")); if (!string.IsNullOrEmpty(email)) { SUser suser = new SUser(); var user = suser.GetUserByEmail(email); SessionBag.Current.User = user; ViewBag.IdUser = user.Id; if (user != null) { return(View(user)); } else { return(RedirectToAction("Logout", "Freelance", new { area = "" })); /*return Redirect(Url.Content("~/Freelance/Logout"))*/; } } else { return(RedirectToAction("Logout", "Freelance", new { area = "" })); //return Redirect(Url.Content("~/Static/index.html")); } }
public async Task <IHttpActionResult> CheckEmail(string email) { IdentityUser user = await UserManager.FindByEmailAsync(email); if (user == null) { return(Json(new { success = true, issue = user, errors = "", tipo = user, UserEmail = "", noskills = "" })); } else { SUser suser = new SUser(); var userskills = suser.GetUserByEmail(email); string noskills = userskills.Skills.Count().ToString(); string mensaje = "<font color='red'>El email de usuario <STRONG>" + user.Email + "</STRONG> esta siendo usado, favor ingresar con la cuenta existente.</font>"; return(Json(new { success = true, issue = user, errors = mensaje, tipo = user, UserEmail = "", noskills = noskills })); } }
public List <ZonaFl.Persistence.Entities.AspNetUsers> GetSuspendUser(string Email, string Estado) { SUser suser = new SUser(); var user = suser.GetUserByEmail(Email); if (Estado.IndexOf("Suspendido") == -1) { user.Status = State.Suspendido.ToString(); } else { user.Status = State.Activo.ToString(); } suser.UpdateUser(user); List <ZonaFl.Persistence.Entities.AspNetUsers> users = new List <ZonaFl.Persistence.Entities.AspNetUsers>(); List <RegisterBindingModel> usersmodel = new List <RegisterBindingModel>(); users = suser.GetAllUsers(); return(users); }
public async Task <IHttpActionResult> RecoverPassword(string email) { // EmailService email = new EmailService(); IdentityMessage im = new IdentityMessage(); SUser suser = new SUser(); var user = suser.GetUserByEmail(email); //string code = await this.AppUserManager.GenerateEmailConfirmationTokenAsync(user.Id); string code = this.AppUserManager.GenerateUserToken(DateTime.Today.ToShortDateString(), user.Id); //var callbackUrl = new Uri(Url.Link("ChangePassword", new { email = email })); string host = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority); var callbackUrl = host + "/Home/index?code=" + code + "#ChangePassword"; //im.Body = "Por favor confirme su cuenta haciendo Click <a href =\"" + callbackUrl + "\">Aquí</a>"; //im.Body = string.Format("Dear {0}<BR/>Thank you for your registration, please click on the below link to comlete your registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>", user.UserName, new Uri(Url.Link("ConfirmEmailRoute", new { userId = user.Id, code = code }))); string body = user.UserName + "," + @"<br /><br />Porfavor haga click en el siguiente link para resuperar la contraseña" + @"<a href = '" + callbackUrl + "'> Recuperar contraseña </a>" + "<br /><br /> si usted no a solicitado cambio de contraseña por favor haga caso omiso de este mensaje.Gracias por ponerse en contacto con Zona FL"; im.Body = body; var smail = SMail.Instance; try { MailMessage mail = new MailMessage("*****@*****.**", email, "Recuperar Password", body); mail.IsBodyHtml = true; smail.Send(mail); } catch (Exception er) { ExceptionResult ere = InternalServerError(er); return(Json(new { success = false, issue = email, errors = ere.Exception.Message, tipo = email, UserEmail = "" })); } return(Json(new { success = true, issue = email, errors = "", tipo = email, UserEmail = email, Url = Url.Content("/Freelance/Logout").ToString() })); }