|
|
@@ -18,8 +18,9 @@ const ( |
|
|
|
) |
|
|
|
|
|
|
|
var ( |
|
|
|
corsHeader string |
|
|
|
password string |
|
|
|
corsHeader string |
|
|
|
password string |
|
|
|
reuseTokens bool |
|
|
|
) |
|
|
|
|
|
|
|
func boardHandler(w http.ResponseWriter, r *http.Request) { |
|
|
@@ -214,7 +215,14 @@ func newKeyHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
errorResponse(400, "Unable to convert request to JSON: "+jsonErr.Error(), w, r) |
|
|
|
return |
|
|
|
} |
|
|
|
key, sqlErr := newKeySql(newKey.PlayerID) |
|
|
|
var key *Key |
|
|
|
var sqlErr error |
|
|
|
if reuseTokens { |
|
|
|
key, sqlErr = keyByPlayer(newKey.PlayerID) |
|
|
|
} |
|
|
|
if (sqlErr != nil && reuseTokens) || !reuseTokens { |
|
|
|
key, sqlErr = newKeySql(newKey.PlayerID) |
|
|
|
} |
|
|
|
if sqlErr != nil { |
|
|
|
fmt.Println(sqlErr) |
|
|
|
errorResponse(500, "Key could not be created: "+sqlErr.Error(), w, r) |
|
|
|