diff --git a/action_get_staff_permissions.go b/action_get_staff_permissions.go index 1ad1604..4822d9d 100644 --- a/action_get_staff_permissions.go +++ b/action_get_staff_permissions.go @@ -14,8 +14,8 @@ func (s Service) GetStaffPermissionsByToken(token string) (doc StaffPermissions) stm, args, _ := s.Builder. Select("dm.id AS device_id, s.id, s.name, s.account_type, s.active, sr.permissions"). From(fmt.Sprintf("%s AS dm", TableDeviceMngt)). - Join(fmt.Sprintf("LEFT JOIN %s s ON s.id = dm.owner_id", TableStaff)). - Join(fmt.Sprintf("LEFT JOIN %s sr ON s.role_id = sr.id", TableStaffRole)). + LeftJoin(fmt.Sprintf("%s AS s ON s.id = dm.owner_id", TableStaff)). + LeftJoin(fmt.Sprintf("%s AS sr ON s.role_id = sr.id", TableStaffRole)). Where("dm.auth_token = ?", token). ToSql() if err := s.DB.GetContext(ctx, &doc, stm, args...); err != nil { diff --git a/action_upsert.go b/action_upsert.go index 00b5429..5d8a45b 100644 --- a/action_upsert.go +++ b/action_upsert.go @@ -3,6 +3,7 @@ package devicemngt import ( "context" "net/http" + "strings" "time" "github.com/Selly-Modules/logger" @@ -73,7 +74,8 @@ func (s Service) Upsert(payload UpsertPayload) { // Auth token if headerData.AuthToken != "" { - authToken = headerData.AuthToken + // Get token only, remove "Bearer " + authToken = strings.Split(headerData.AuthToken, " ")[1] } else { authToken = payload.AuthToken }