コード例 #1
0
        public ActionResult ChangePassword(SignInModel model, string returnUrl)
        {
            User user = null;

            try
            {
                user = new SignInHandler().Handle2(model);
                return RedirectToAction("SignIn");
            }
            catch (ValidationException e)
            {
                ModelState.AddModelError(e.Key, e.Message);
                return this.View();
            }
        }
コード例 #2
0
ファイル: LogInHandler.cs プロジェクト: egarciac/SwissKipTeam
 public User Handle2(SignInModel form)
 {
     User user = this.Find2(form.Email);
      if (user!=null)
      {
          if (form.Password1 != form.Password2)
              throw new ValidationException("Passwords are not equals.");
          else
          {
              user.Password = form.Password1;
              user.Tried = 0;
              user.Blocked = false;
              Current.Connection.Update(user);
              return user;
          }
      }
      throw new ValidationException("Your Email doesn't have any account associated.");
 }
コード例 #3
0
ファイル: LogInHandler.cs プロジェクト: egarciac/SwissKipTeam
        public User Handle(SignInModel form)
        {
            var user = this.Find(form.Username);
             if (user!=null)
             {
                 if (user.Banned)
                 {
                     DateTime fecha = (DateTime)user.ModifiedDate;
                     if (System.DateTime.Now > fecha.AddDays(1))
                     {
                         user.Banned = false;
                         user.ModifiedDate = System.DateTime.Now;
                         user.Tried = 0;
                         Current.Connection.Update(user);
                     }
                     else
                         throw new ValidationException("Your account is still banned");
                 }

                 if (user.PasswordMatches(form.Password))
                    return user;
                 else
                 {
                    user.Tried = user.Tried + 1;
                    Current.Connection.Update(user);
                    if (user.Tried >= 3) //Number of Tries
                    {
                        user.Banned = true;
                        Current.Connection.Update(user);
                        throw new ValidationException("Your account has been banned");
                    }
                 }

             }
             throw new ValidationException("Invalid Username or Password");
        }
コード例 #4
0
        public ActionResult SignIn(string V, string type, SignInModel model, string returnUrl)
        {
            User user = null;
            if (ModelState.IsValid)
            {
                try
                {
                    user = new SignInHandler().Handle(model);
                    if (user.Banned)
                        return RedirectToAction("BannedAccount");
                    //if (user.Blocked)
                    //    return RedirectToAction("BlockedAccount");

                    if (type != null)
                    {
                        Session["AccessDenied"] = 1;
                        return RedirectToAction("Signin2", "Registration", new { userId = V, type = type });
                    }
                }
                catch (ValidationException e)
                {
                    ModelState.AddModelError(e.Key, e.Message);
                }
            }
            else
            {
                ModelState.AddModelError("", "Forgot username or passoword");
                return this.View();
            }

            if (!ModelState.IsValid)
                return this.View();

            AuthenticationService.SignIn(user);
            Session["path"] = Server.MapPath("~/Swisskip/") + user.UserName;

            //Sent TOKEN by email
            int newValue = SignInHandler.SendInvitation(user);

            //Added Token into account
            UsersAddHandler usersAddHandler = new UsersAddHandler();
            user.TokenNumber = newValue;
            usersAddHandler.Update(user);

            //Validating data entry

            if (user.ColourId == 0 && user.IsOwner == false)
            {
                return RedirectToAction("Reminder");
            }
            else if (user.ColourId == 0 && user.IsOwner)
            {
                return RedirectToAction("MissingInfo", new { id = user.Id });
            }

            Session["AccessDenied"] = 1;
            return RedirectToAction("Confirm");
        }
コード例 #5
0
        public ActionResult Maintained(int? userId, SignInModel model, string returnUrl)
        {
            User user = null;
            if (ModelState.IsValid)
            {
                try
                {
                    user = new SignInHandler().Handle(model);
                    if (user.Banned)
                        return RedirectToAction("BannedAccount");
                    //if (user.Blocked)
                    //    return RedirectToAction("BlockedAccount");
                }
                catch (ValidationException e)
                {
                    ModelState.AddModelError(e.Key, e.Message);
                }
            }
            else
            {
                ModelState.AddModelError("", "Forgot username or passoword");
                return this.View();
            }

            if (!ModelState.IsValid)
                return this.View();

            AuthenticationService.SignIn(user);
            Session["path"] = Server.MapPath("~/Swisskip/") + user.UserName;

            //Sent TOKEN by email
            int newValue = SignInHandler.SendInvitation(user);

            //Added Token into account
            UsersAddHandler usersAddHandler = new UsersAddHandler();
            user.TokenNumber = newValue;
            usersAddHandler.Update(user);

            return RedirectToAction("Confirm");
        }