mirror of
https://wiilab.wiimart.org/wiimart/WiiSOAP
synced 2025-09-05 21:11:02 +02:00
Properly implement SyncRegistration
This additionally updates GetRegistrationInfo to use similar logic. The two are the exact same function within both the ECDK and the Wii Shop Channel's ESHOP SDK - they differ only in name, authentication level, and a single key.
This commit is contained in:
parent
8009f1a510
commit
3182d4dd7e
32
ias.go
32
ias.go
@ -30,6 +30,7 @@ import (
|
||||
)
|
||||
|
||||
var registerUser *sql.Stmt
|
||||
var syncUser *sql.Stmt
|
||||
|
||||
func iasInitialize() {
|
||||
var err error
|
||||
@ -37,6 +38,11 @@ func iasInitialize() {
|
||||
if err != nil {
|
||||
log.Fatalf("ias initialize: error preparing statement: %v\n", err)
|
||||
}
|
||||
|
||||
syncUser, err = db.Prepare(`SELECT userbase.AccountId, userbase.DeviceCode, userbase.DeviceTokenUnhashed FROM userbase WHERE Language = ? AND Country = ? AND Region = ? AND DeviceId = ?`)
|
||||
if err != nil {
|
||||
log.Fatalf("ias initialize: error preparing statement: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func checkRegistration(e *Envelope) {
|
||||
@ -59,26 +65,32 @@ func getChallenge(e *Envelope) {
|
||||
}
|
||||
|
||||
func getRegistrationInfo(e *Envelope) {
|
||||
reason := "how dirty. ;3"
|
||||
accountId, err := getKey(e.doc, "AccountId")
|
||||
if err != nil {
|
||||
e.Error(7, reason, err)
|
||||
// GetRegistrationInfo is SyncRegistration with authentication and an additional key.
|
||||
syncRegistration(e)
|
||||
|
||||
// This _must_ be POINTS.
|
||||
// It does not appear to be observed by any known client,
|
||||
// but is sent by Nintendo in official requests.
|
||||
e.AddKVNode("Currency", "POINTS")
|
||||
}
|
||||
|
||||
deviceCode, err := getKey(e.doc, "DeviceCode")
|
||||
func syncRegistration(e *Envelope) {
|
||||
var accountId string
|
||||
var deviceCode string
|
||||
var deviceToken string
|
||||
|
||||
user := syncUser.QueryRow(e.Language(), e.Country(), e.Region(), e.DeviceId())
|
||||
err := user.Scan(&accountId, &deviceCode, &deviceToken)
|
||||
if err != nil {
|
||||
e.Error(7, reason, err)
|
||||
e.Error(7, "An error occurred querying the database.", err)
|
||||
}
|
||||
|
||||
e.AddKVNode("AccountId", accountId)
|
||||
e.AddKVNode("DeviceToken", "00000000")
|
||||
e.AddKVNode("DeviceToken", deviceToken)
|
||||
e.AddKVNode("DeviceTokenExpired", "false")
|
||||
e.AddKVNode("Country", e.Country())
|
||||
e.AddKVNode("ExtAccountId", "")
|
||||
e.AddKVNode("DeviceCode", deviceCode)
|
||||
e.AddKVNode("DeviceStatus", "R")
|
||||
// This _must_ be POINTS.
|
||||
e.AddKVNode("Currency", "POINTS")
|
||||
}
|
||||
|
||||
func register(e *Envelope) {
|
||||
|
1
main.go
1
main.go
@ -95,6 +95,7 @@ func main() {
|
||||
ias.Unauthenticated("CheckRegistration", checkRegistration)
|
||||
ias.Unauthenticated("GetChallenge", getChallenge)
|
||||
ias.Authenticated("GetRegistrationInfo", getRegistrationInfo)
|
||||
ias.Unauthenticated("SyncRegistration", syncRegistration)
|
||||
ias.Unauthenticated("Register", register)
|
||||
ias.Authenticated("Unregister", unregister)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user