public ActionResult ForgottenPassword(string email)
        {
            using (_securityService.BeginSystemContext())
            {
                var q = new EntityQuery2("User");
                q.WhereIs("Email", email);
                q.WhereIs("IsActive", true);
                Entity user = _entityService.Query(q).SingleOrDefault();
                if (user == null)
                {
                    ModelState.AddModelError("email", string.Format("В системата няма активен потребител с имейл \"{0}\". За помощ: тел. 02 8110296.", email));
                    return(View());
                }
                else
                {
                    var recoveryCode = Guid.NewGuid().ToString();

                    var update = new EntityUpdate(user.Name, user.Id);
                    update.Set("RecoveryCode", recoveryCode);
                    var result = _entityService.Update(update);
                    if (result.Success)
                    {
                        return(View("ForgottenPassword_Success", (object)email));
                    }
                    else
                    {
                        ModelState.AddModelError("email", "Възникна грешка при стартиране на процеса по възстановяване на забравена парола. За помощ: тел. 02 8110296.");
                        return(View());
                    }
                }
            }
        }
Beispiel #2
0
 public IEnumerable <Entity> Search(EntityQuery2 query)
 {
     return(_entityService.Query(query));
 }