public static void OnCommand_Auth(CommandEventArgs e)
        {
            Mobile m = e.Mobile;

            if (m == null)
            {
                return;
            }

            if (e.ArgString == null || e.ArgString == "")
            {
                m.SendMessage("Usage: [auth <key>");
                return;
            }

            if (!_AuthList.ContainsKey(m.Serial))
            {
                m.SendMessage("You do not have any account requests that need authorization");
                return;
            }

            ChangeRequest req = _AuthList[m.Serial];

            bool Auth = req.Authenticate(e.ArgString);

            if (Auth)
            {
                switch (req.RequestType)
                {
                case RequestType.ChangeEmail:
                {
                    Account acc = (Account)m.Account;

                    if (acc != null)
                    {
                        acc.SetTag("EMAIL", req.RequestString);
                        m.SendMessage("Your registered email address has been changed.");
                    }

                    break;
                }

                case RequestType.Email:
                {
                    Account acc = (Account)m.Account;

                    if (acc != null)
                    {
                        acc.AddTag("EMAIL", req.RequestString);
                        m.SendMessage("Your email address has been registered with this account.");
                    }

                    break;
                }

                case RequestType.Password:
                {
                    Account acc = (Account)m.Account;

                    if (acc != null)
                    {
                        acc.SetPassword(req.RequestString);
                        m.SendMessage("Your account password has been changed.");
                    }

                    break;
                }
                }

                if (_Timers.ContainsKey(m.Serial))
                {
                    ChangeRequestTimer timer = _Timers[m.Serial];
                    timer.Stop();

                    _Timers.Remove(m.Serial);
                    _AuthList.Remove(m.Serial);
                }
            }
            else
            {
                m.SendMessage("That key was invalid");
            }
        }
        public static void Command_Register(Server.Commands.CommandEventArgs e)
        {
            Mobile m = e.Mobile;

            if (AutoRestart.Restarting)
            {
                m.SendMessage("Validation requests expire during server wars. Please re-request after server restart.");
                return;
            }

            string key = e.ArgString;

            if (key == null || key == "")
            {
                m.SendMessage("You must enter a valid key.");
                return;
            }

            Account a = m.Account as Account;

            if (a == null)               // Sanity
            {
                return;
            }

            AuthKey ak = GetKey(a);

            if (ak == null)
            {
                m.SendMessage("You have no validations pending.");
                return;
            }
            else if (ak.Expired)
            {
                m.SendMessage("That validation key has expired.");
                return;
            }
            else if (ak.Key != key)
            {
                m.SendMessage("That validation key is incorrect.");
                return;
            }

            switch (ak.Type)
            {
            case AuthType.Register:
                string email = ak.State as string;
                a.SetTag("EMail", email);
                m.SendMessage("Your account has been registered.", email);
                break;

            case AuthType.EMail:
                a.RemoveTag("EMail");
                m.SendMessage("Your e-mail address has been reset.");
                m.SendMessage("You will be prompted to re-register on your next login.");
                break;

            case AuthType.Password:
                string pw = ak.State as string;
                a.SetPassword(pw);
                m.SendMessage("Your password has been changed.");
                break;

            default:
                m.SendMessage("ERROR: Invalid AuthType, please page an administrator for assistance.");
                break;
            }

            RemoveKey(a);
        }
Beispiel #3
0
        public static void UpdateUOPasswords( )
        {
            //Console.WriteLine( "Getting New Passwords..." );
            try
            {
                ArrayList      ToUpdatePWFromDB = new ArrayList( );
                OdbcConnection Connection       = new OdbcConnection(ConnectionString);

                Connection.Open( );
                OdbcCommand Command = Connection.CreateCommand( );

                Command.CommandText = string.Format("SELECT name,password FROM {0} WHERE state='{1}'", DatabaseTable, ( int )Status.PWChanged);
                OdbcDataReader reader = Command.ExecuteReader( );

                QueryCount += 1;

                while (reader.Read( ))
                {
                    string username = reader.GetString(0);
                    string password = reader.GetString(1);

                    Account AtoUpdate = Accounts.GetAccount(username) as Account;

                    if (AtoUpdate != null)
                    {
                        PasswordProtection PWMode   = AccountHandler.ProtectPasswords;
                        string             Password = "";

                        switch (PWMode)
                        {
                        case PasswordProtection.None: { Password = AtoUpdate.PlainPassword; } break;

                        case PasswordProtection.Crypt: { Password = AtoUpdate.CryptPassword; } break;

                        default: { Password = AtoUpdate.NewCryptPassword; } break;
                        }

                        if (Password == null || Password == "" || Password != password)
                        {
                            AtoUpdate.SetPassword(password);
                            ToUpdatePWFromDB.Add(AtoUpdate);
                        }
                    }
                }
                reader.Close( );

                //Console.WriteLine( "Updating Database..." );
                foreach (Account a in ToUpdatePWFromDB)
                {
                    PasswordProtection PWModeU   = AccountHandler.ProtectPasswords;
                    string             PasswordU = "";

                    switch (PWModeU)
                    {
                    case PasswordProtection.None: { PasswordU = a.PlainPassword; } break;

                    case PasswordProtection.Crypt: { PasswordU = a.CryptPassword; } break;

                    default: { PasswordU = a.NewCryptPassword; } break;
                    }

                    QueryCount += 1;

                    Command.CommandText = string.Format("UPDATE {0} SET state='{1}',password='******' WHERE name='{3}'", DatabaseTable, ( int )Status.Active, PasswordU, a.Username);
                    Command.ExecuteNonQuery( );
                }

                Connection.Close( );

                Console.WriteLine("[{0} In-game Passwords Changed] ", ToUpdatePWFromDB.Count);
            }
            catch (System.Exception e)
            {
                Console.WriteLine("[In-Game Password Change] Error...");
                Console.WriteLine(e);
            }
        }