Esempio n. 1
0
        public bool ChangeForgottenPassword(ReqChangeForgottenPassword req)
        {
            if (string.IsNullOrWhiteSpace(req.Keyword))
            {
                throw new APIException("Keyword required", ErrorTypes.ValidationError);
            }
            if ((req.NewPassword ?? "").Length < 6)
            {
                throw new APIException("Password length cannot be less than six", ErrorTypes.ValidationError);
            }
            if (req.NewPassword != req.NewPasswordAgain)
            {
                throw new APIException("Passwords not match", ErrorTypes.ValidationError);
            }


            var member = Provider.Database.Read <Member>("Keyword = {0}", req.Keyword);

            if (member == null)
            {
                throw new APIException("No such member with the keyword provided");
            }


            try
            {
                member.Password = System.Utility.MD5(req.NewPassword);
                member.State    = MemberStates.Confirmed;
                member.Keyword  = "";
                member.Save();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 2
0
 public bool ChangeForgottenPassword(ReqChangeForgottenPassword req)
 {
     return(Call <bool, ReqChangeForgottenPassword>(req, MethodBase.GetCurrentMethod().Name));
 }