Ejemplo n.º 1
0
        public bool validateCode(string resetCode, string password)
        {
            LibPoco.Users user = RetrieveUser("", resetCode);
            if (user != null)
            {
                if (user.PasswordResetCode == resetCode)
                {
                    var pwd = new CreatePasswords(password, user.FirstName + user.LastName);
                    user.PasswordResetCode = "";
                    user.Password          = pwd.Password;
                    user.Salt = pwd.Salt;
                    using (var db = Setup.DbFactory)
                    {
                        db.Open();

                        using (var txn = db.BeginTransaction())
                        {
                            db.Update(user);

                            txn.Commit();
                        }
                    }

                    email.SendMail("Your Password was Reset", "Password Reset", user.Email, false);
                    return(true);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public void UpdatePassword(string oldPassword, string newPassword, string confirmNewPassword)
        {
            if (newPassword != confirmNewPassword)
            {
                throw new Exceptions.InvalidDataException("New password and confirm new password do not match.");
            }

            var login = new LibLogic.Login(details.Email, oldPassword);

            login.Execute();

            if (!login.LoggedIn)
            {
                throw new Exceptions.InvalidDataException("Invalid old password");
            }


            var pwd = new CreatePasswords(newPassword, details.FirstName + details.LastName);

            using (var cn = LibLogic.Setup.DbFactory)
            {
                cn.Open();

                details.Password = pwd.Password;
                details.Salt     = pwd.Salt;

                cn.Update(details);
            }
        }
Ejemplo n.º 3
0
        public int Execute()
        {
            ValidateData();

            using (var db = Setup.DbFactory)
            {
                db.Open();


                using (var txn = db.BeginTransaction())
                {
                    var pwd = new CreatePasswords(details.Password, details.Firstname + details.Lastname);

                    var userid = db.Insert(new LibPoco.Users(
                                               details.Email,
                                               pwd.Password,
                                               pwd.Salt,
                                               details.Firstname,
                                               details.Lastname,
                                               isAdmin,
                                               DateTime.UtcNow,
                                               "",
                                               "",
                                               "",

                                               RequiresBetaKey()


                                               ));

                    if (RequiresBetaKey())
                    {
                        betaKey.IsUsed = true;
                        db.Update(betaKey);
                    }

                    txn.Commit();

                    if (isAdmin == false)
                    {
                        EmailAccountCreation();
                    }

                    return((int)userid);
                }
            }
        }