800 | | #if defined _NETCODE_FAKE_AUTH |
801 | | if (!dontchechtheacc) |
802 | | { |
803 | | #endif |
804 | | if (!vold || strcmp (vStr, vold)) |
805 | | { |
806 | | packet.Initialize (SMSG_AUTH_RESPONSE, 1); |
807 | | packet << uint8 (AUTH_UNKNOWN_ACCOUNT); |
808 | | SendPacket (packet); |
809 | | delete result; |
810 | | OPENSSL_free ((void*) sStr); |
811 | | OPENSSL_free ((void*) vStr); |
812 | | |
813 | | sLog.outError ("WorldSocket::HandleAuthSession: User not logged."); |
814 | | return -1; |
815 | | } |
816 | | #if defined _NETCODE_FAKE_AUTH |
817 | | } |
818 | | #endif |
| 789 | if (!vold || strcmp (vStr, vold)) |
| 790 | { |
| 791 | packet.Initialize (SMSG_AUTH_RESPONSE, 1); |
| 792 | packet << uint8 (AUTH_UNKNOWN_ACCOUNT); |
| 793 | SendPacket (packet); |
| 794 | delete result; |
| 795 | OPENSSL_free ((void*) sStr); |
| 796 | OPENSSL_free ((void*) vStr); |
| 797 | |
| 798 | sLog.outBasic ("WorldSocket::HandleAuthSession: User not logged."); |
| 799 | return -1; |
| 800 | } |
850 | | #if defined _NETCODE_FAKE_AUTH |
851 | | if (!dontchechtheacc) |
852 | | { |
853 | | #endif |
854 | | // Re-check account ban (same check as in realmd) |
855 | | QueryResult *banresult = |
856 | | loginDatabase.PQuery ("SELECT " |
857 | | "bandate, " |
858 | | "unbandate " |
859 | | "FROM account_banned " |
860 | | "WHERE id = '%u' " |
861 | | "AND active = 1", |
862 | | id); |
863 | | |
864 | | if (banresult) // if account banned |
865 | | { |
866 | | packet.Initialize (SMSG_AUTH_RESPONSE, 1); |
867 | | packet << uint8 (AUTH_BANNED); |
868 | | SendPacket (packet); |
869 | | |
870 | | delete banresult; |
871 | | |
872 | | sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); |
873 | | return -1; |
874 | | } |
875 | | |
876 | | // Check locked state for server |
877 | | AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit (); |
878 | | |
879 | | if (allowedAccountType > SEC_PLAYER && security < allowedAccountType) |
880 | | { |
881 | | WorldPacket Packet (SMSG_AUTH_RESPONSE, 1); |
882 | | Packet << uint8 (AUTH_UNAVAILABLE); |
883 | | |
884 | | SendPacket (packet); |
885 | | |
886 | | sLog.outBasic ("WorldSocket::HandleAuthSession: User tryes to login but his security level is not enough"); |
887 | | return -1; |
888 | | } |
889 | | |
890 | | // Check that Key and account name are the same on client and server |
891 | | Sha1Hash sha; |
892 | | |
893 | | uint32 t = 0; |
894 | | uint32 seed = m_Seed; |
895 | | |
896 | | sha.UpdateData (account); |
897 | | sha.UpdateData ((uint8 *) & t, 4); |
898 | | sha.UpdateData ((uint8 *) & clientSeed, 4); |
899 | | sha.UpdateData ((uint8 *) & seed, 4); |
900 | | sha.UpdateBigNumbers (&K, NULL); |
901 | | sha.Finalize (); |
902 | | |
903 | | if (memcmp (sha.GetDigest (), digest, 20)) |
904 | | { |
905 | | packet.Initialize (SMSG_AUTH_RESPONSE, 1); |
906 | | packet << uint8 (AUTH_FAILED); |
907 | | |
908 | | SendPacket (packet); |
909 | | |
910 | | sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); |
911 | | return -1; |
912 | | } |
913 | | #if defined _NETCODE_FAKE_AUTH |
914 | | } |
915 | | #endif |
| 832 | // Re-check account ban (same check as in realmd) |
| 833 | QueryResult *banresult = |
| 834 | loginDatabase.PQuery ("SELECT " |
| 835 | "bandate, " |
| 836 | "unbandate " |
| 837 | "FROM account_banned " |
| 838 | "WHERE id = '%u' " |
| 839 | "AND active = 1", |
| 840 | id); |
| 841 | |
| 842 | if (banresult) // if account banned |
| 843 | { |
| 844 | packet.Initialize (SMSG_AUTH_RESPONSE, 1); |
| 845 | packet << uint8 (AUTH_BANNED); |
| 846 | SendPacket (packet); |
| 847 | |
| 848 | delete banresult; |
| 849 | |
| 850 | sLog.outBasic ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); |
| 851 | return -1; |
| 852 | } |
| 853 | |
| 854 | // Check locked state for server |
| 855 | AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit (); |
| 856 | |
| 857 | if (allowedAccountType > SEC_PLAYER && security < allowedAccountType) |
| 858 | { |
| 859 | WorldPacket Packet (SMSG_AUTH_RESPONSE, 1); |
| 860 | Packet << uint8 (AUTH_UNAVAILABLE); |
| 861 | |
| 862 | SendPacket (packet); |
| 863 | |
| 864 | sLog.outBasic ("WorldSocket::HandleAuthSession: User tryes to login but his security level is not enough"); |
| 865 | return -1; |
| 866 | } |
| 867 | |
| 868 | // Check that Key and account name are the same on client and server |
| 869 | Sha1Hash sha; |
| 870 | |
| 871 | uint32 t = 0; |
| 872 | uint32 seed = m_Seed; |
| 873 | |
| 874 | sha.UpdateData (account); |
| 875 | sha.UpdateData ((uint8 *) & t, 4); |
| 876 | sha.UpdateData ((uint8 *) & clientSeed, 4); |
| 877 | sha.UpdateData ((uint8 *) & seed, 4); |
| 878 | sha.UpdateBigNumbers (&K, NULL); |
| 879 | sha.Finalize (); |
| 880 | |
| 881 | if (memcmp (sha.GetDigest (), digest, 20)) |
| 882 | { |
| 883 | packet.Initialize (SMSG_AUTH_RESPONSE, 1); |
| 884 | packet << uint8 (AUTH_FAILED); |
| 885 | |
| 886 | SendPacket (packet); |
| 887 | |
| 888 | sLog.outBasic ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); |
| 889 | return -1; |
| 890 | } |