Пример #1
0
        public bool validateCode(string resetCode, string password)
        {
            Majorsilence.Vpn.Poco.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 = InitializeSettings.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);
        }
Пример #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 Majorsilence.Vpn.Logic.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 = Majorsilence.Vpn.Logic.InitializeSettings.DbFactory)
            {
                cn.Open();

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

                cn.Update(details);
            }
        }
Пример #3
0
        public int Execute()
        {
            ValidateData();

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


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

                    var userid = db.Insert(new Majorsilence.Vpn.Poco.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);
                }
            }
        }