[PD1] Fixed stuff. Unmarshal still returns map[string]interface{}, need to fix

This commit is contained in:
Afonso Franco 2024-04-19 11:55:16 +01:00
parent c131aa2aea
commit 39a0e5c01f
Signed by: afonso
SSH key fingerprint: SHA256:aiLbdlPwXKJS5wMnghdtod0SPy8imZjlVvCyUX9DJNk
6 changed files with 127 additions and 96 deletions

View file

@ -154,3 +154,22 @@ func (ds DataStore) GetUserCertificate(uid string) protocol.Packet {
}
return protocol.NewSendUserCertPacket(uid, userCert)
}
func userExists(db *sql.DB, uid string) bool {
// Prepare the SQL statement for checking if a user exists
query := `
SELECT COUNT(*)
FROM users
WHERE UID = ?
`
var count int
// Execute the SQL query
err := db.QueryRow(query, uid).Scan(&count)
if err != nil {
log.Panicln("Error checking if user exists")
}
// If count is greater than 0, the user exists
return count > 0
}