Fix NPE in compatHandler
This commit is contained in:
@@ -296,12 +296,12 @@ func (h CompatHandler) Info(g *gin.Context) ginresp.HTTPResponse {
|
||||
}
|
||||
|
||||
keytok, err := h.database.GetKeyTokenByToken(ctx, *data.UserKey)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if err != nil {
|
||||
return ginresp.CompatAPIError(0, "Failed to query token")
|
||||
}
|
||||
if keytok == nil {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if !keytok.IsAdmin(user.UserID) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
@@ -404,12 +404,12 @@ func (h CompatHandler) Ack(g *gin.Context) ginresp.HTTPResponse {
|
||||
}
|
||||
|
||||
keytok, err := h.database.GetKeyTokenByToken(ctx, *data.UserKey)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if err != nil {
|
||||
return ginresp.CompatAPIError(0, "Failed to query token")
|
||||
}
|
||||
if keytok == nil {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if !keytok.IsAdmin(user.UserID) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
@@ -506,12 +506,12 @@ func (h CompatHandler) Requery(g *gin.Context) ginresp.HTTPResponse {
|
||||
}
|
||||
|
||||
keytok, err := h.database.GetKeyTokenByToken(ctx, *data.UserKey)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if err != nil {
|
||||
return ginresp.CompatAPIError(0, "Failed to query token")
|
||||
}
|
||||
if keytok == nil {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if !keytok.IsAdmin(user.UserID) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
@@ -623,12 +623,12 @@ func (h CompatHandler) Update(g *gin.Context) ginresp.HTTPResponse {
|
||||
}
|
||||
|
||||
keytok, err := h.database.GetKeyTokenByToken(ctx, *data.UserKey)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if err != nil {
|
||||
return ginresp.CompatAPIError(0, "Failed to query token")
|
||||
}
|
||||
if keytok == nil {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if !keytok.IsAdmin(user.UserID) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
@@ -663,7 +663,7 @@ func (h CompatHandler) Update(g *gin.Context) ginresp.HTTPResponse {
|
||||
|
||||
_, err = h.database.CreateClient(ctx, user.UserID, models.ClientTypeAndroid, *data.FCMToken, "compat", "compat")
|
||||
if err != nil {
|
||||
return ginresp.CompatAPIError(0, "Failed to delete client")
|
||||
return ginresp.CompatAPIError(0, "Failed to create client")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -753,12 +753,12 @@ func (h CompatHandler) Expand(g *gin.Context) ginresp.HTTPResponse {
|
||||
}
|
||||
|
||||
keytok, err := h.database.GetKeyTokenByToken(ctx, *data.UserKey)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if err != nil {
|
||||
return ginresp.CompatAPIError(0, "Failed to query token")
|
||||
}
|
||||
if keytok == nil {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if !keytok.IsAdmin(user.UserID) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
@@ -872,12 +872,12 @@ func (h CompatHandler) Upgrade(g *gin.Context) ginresp.HTTPResponse {
|
||||
}
|
||||
|
||||
keytok, err := h.database.GetKeyTokenByToken(ctx, *data.UserKey)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if err != nil {
|
||||
return ginresp.CompatAPIError(0, "Failed to query token")
|
||||
}
|
||||
if keytok == nil {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
if !keytok.IsAdmin(user.UserID) {
|
||||
return ginresp.CompatAPIError(204, "Authentification failed")
|
||||
}
|
||||
|
Reference in New Issue
Block a user