public static void Authenticate( NetState state, PacketReader pvSrc )
{
string user = pvSrc.ReadString( 30 );
string pw = pvSrc.ReadString( 30 );
Account a = Accounts.GetAccount( user ) as Account;
if ( a == null )
{
state.Send( new Login( LoginResponse.NoUser ) );
Console.WriteLine( "ADMIN: Invalid username '{0}' from {1}", user, state );
DelayedDisconnect( state );
}
else if ( !a.HasAccess( state ) )
{
state.Send( new Login( LoginResponse.BadIP ) );
Console.WriteLine( "ADMIN: Access to '{0}' from {1} denied.", user, state );
DelayedDisconnect( state );
}
else if ( !a.CheckPassword( pw ) )
{
state.Send( new Login( LoginResponse.BadPass ) );
Console.WriteLine( "ADMIN: Invalid password for user '{0}' from {1}", user, state );
DelayedDisconnect( state );
}
else if ( a.AccessLevel < AccessLevel.Administrator || a.Banned )
{
Console.WriteLine( "ADMIN: Account '{0}' does not have admin access. Connection Denied.", user );
state.Send( new Login( LoginResponse.NoAccess ) );
DelayedDisconnect( state );
}
else
{
Console.WriteLine( "ADMIN: Access granted to '{0}' from {1}", user, state );
state.Account = a;
a.LogAccess( state );
a.LastLogin = DateTime.Now;
state.Send( new Login( LoginResponse.OK ) );
TightTrimConsoleData();
state.Send( Compress( new ConsoleData( m_ConsoleData.ToString() ) ) );
m_Auth.Add( state );
}
}