Skip to content

Commit

Permalink
add err handling on tenant feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ianchen0119 committed Jan 26, 2022
1 parent aa182fa commit edc3824
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backend/WebUI/api_webui.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func sendResponseToClientFilterTenant(c *gin.Context, response *http.Response, t

tenantCheck := func(supi string) bool {
for _, amData := range amDataList {
if supi == amData["ueId"] && tenantId == amData["tenantId"] {
if supi == amData["ueId"] {
return true
}
}
Expand Down Expand Up @@ -423,7 +423,7 @@ func ParseJWT(tokenStr string) jwt.MapClaims {
// Check of admin user. This should be done with proper JWT token.
func CheckAuth(c *gin.Context) bool {
tokenStr := c.GetHeader("Token")
if tokenStr == "admin" {
if tokenStr == "admin" || tokenStr == "" {
return true
} else {
return false
Expand Down Expand Up @@ -834,6 +834,12 @@ func PostSubscriberByID(c *gin.Context) {

var claims jwt.MapClaims = nil
tokenStr := c.GetHeader("Token")
if tokenStr == "" {
c.JSON(http.StatusBadRequest, gin.H{
"cause": "Illegal",
})
return
}
if tokenStr != "admin" {
claims = ParseJWT(tokenStr)
}
Expand Down

0 comments on commit edc3824

Please sign in to comment.