admin user auth working

This commit is contained in:
afeiszli
2021-05-29 20:18:22 +00:00
parent 02ec2df48a
commit 4f531e1c54
7 changed files with 33 additions and 59 deletions

View File

@@ -64,10 +64,6 @@ func SecurityCheck(netname, token string) error {
return err
}
if hasnetwork && !networkexists {
//errorResponse = models.ErrorResponse{
// Code: http.StatusNotFound, Message: "W1R3: This network does not exist.",
//}
//returnErrorResponse(w, r, errorResponse)
return errors.New("This network does not exist")
}
@@ -81,14 +77,12 @@ func SecurityCheck(netname, token string) error {
authToken = tokenSplit[1]
}
//all endpoints here require master so not as complicated
//still might not be a good way of doing this
if !hasBearer || !authenticateMaster(authToken) {
//errorResponse = models.ErrorResponse{
// Code: http.StatusUnauthorized, Message: "W1R3: You are unauthorized to access this endpoint.",
// }
// returnErrorResponse(w, r, errorResponse)
return errors.New("You are unauthorized to access this endpoint")
} //else {
_, isadmin, err := functions.VerifyUserToken(authToken)
if err != nil || !isadmin {
return errors.New("You are unauthorized to access this endpoint")
}
}
return nil
}