| 1134 | } |
| 1135 | |
| 1136 | bool AdminCache::BindAdminIdentity(AdminId id, const char *auth, const char *ident) |
| 1137 | { |
| 1138 | if (ident[0] == '\0') |
| 1139 | { |
| 1140 | return false; |
| 1141 | } |
| 1142 | |
| 1143 | AdminUser *pUser = (AdminUser *)m_pMemory->GetAddress(id); |
| 1144 | if (!pUser || pUser->magic != USR_MAGIC_SET) |
| 1145 | { |
| 1146 | return false; |
| 1147 | } |
| 1148 | |
| 1149 | AuthMethod *method; |
| 1150 | if (!m_AuthTables.retrieve(auth, &method)) |
| 1151 | return false; |
| 1152 | |
| 1153 | /* If the auth type is steam, the id could be in a number of formats. Unify it. */ |
| 1154 | char steamIdent[16]; |
| 1155 | if (strcmp(auth, "steam") == 0) |
| 1156 | { |
| 1157 | if (!GetUnifiedSteamIdentity(ident, steamIdent, sizeof(steamIdent))) |
| 1158 | return false; |
| 1159 | |
| 1160 | ident = steamIdent; |
| 1161 | } |
| 1162 | |
| 1163 | if (method->identities.contains(ident)) |
| 1164 | return false; |
| 1165 | |
| 1166 | int i_ident = m_pStrings->AddString(ident); |
| 1167 | |
| 1168 | pUser = (AdminUser *)m_pMemory->GetAddress(id); |
| 1169 | pUser->auth.identidx = i_ident; |
| 1170 | GetMethodIndex(auth, &pUser->auth.index); |
| 1171 | |
| 1172 | return method->identities.insert(ident, id); |
| 1173 | } |
| 1174 | |
| 1175 | AdminId AdminCache::FindAdminByIdentity(const char *auth, const char *identity) |
| 1176 | { |
no test coverage detected