From a6746c056270aeb7f1a3afe7748ecf2feb09382c Mon Sep 17 00:00:00 2001 From: Nam Huynh Date: Sat, 21 Aug 2021 19:46:28 +0700 Subject: [PATCH] add more fields to device data --- action_get_staff_permissions.go | 4 ++-- action_upsert.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) 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 }