fix: need to cast appId as string,then parse to int
This commit is contained in:
parent
846e5df758
commit
669a6eaf6d
|
@ -87,14 +87,20 @@ func githubRestVerifyMiddleware(db *gorm.DB) mux.MiddlewareFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
appId, ok := claims["iss"].(uint)
|
appId, ok := claims["iss"].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
http.Error(w, "Invalid JWT", http.StatusUnauthorized)
|
http.Error(w, "Invalid JWT", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appIdInt, err := strconv.Atoi(appId)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Invalid JWT", http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
appRecord := &model.Apps{}
|
appRecord := &model.Apps{}
|
||||||
appRecord.ID = appId
|
appRecord.ID = uint(appIdInt)
|
||||||
|
|
||||||
if err := db.First(appRecord).Error; err != nil {
|
if err := db.First(appRecord).Error; err != nil {
|
||||||
http.Error(w, "Invalid JWT", http.StatusUnauthorized)
|
http.Error(w, "Invalid JWT", http.StatusUnauthorized)
|
||||||
|
@ -139,7 +145,7 @@ func githubRestVerifyMiddleware(db *gorm.DB) mux.MiddlewareFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if appId != uint(installIdInt) {
|
if appIdInt != installIdInt {
|
||||||
http.Error(w, "Invalid Install", http.StatusUnauthorized)
|
http.Error(w, "Invalid Install", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue