Skip to content

Commit 6209c4d

Browse files
authored
Merge pull request #165 from Vicg853/fix/role-update
Unable to update user role fix
2 parents 773213e + 1efa419 commit 6209c4d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

server/test/update_user_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ func updateUserTest(t *testing.T, s TestSetup) {
2424
})
2525

2626
user := *signupRes.User
27+
//! - Found out by testing
28+
//! that the 'supplier' role was being accepted by the server
29+
//! even though that it doesn't exist in the database.
30+
//! (checked it by doing fmt.Println() on role envs)
31+
//! But I'm not removing it as there is maybe a reason for it to be be here...
32+
//! - Appart from that, by removing it test returns 'unauthorized' successfully
2733
adminRole := "supplier"
2834
userRole := "user"
2935
newRoles := []*string{&adminRole, &userRole}

server/utils/validator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func IsValidOrigin(url string) bool {
5454
// IsValidRoles validates roles
5555
func IsValidRoles(userRoles []string, roles []string) bool {
5656
valid := true
57-
for _, role := range roles {
58-
if !StringSliceContains(userRoles, role) {
57+
for _, userRole := range userRoles {
58+
if !StringSliceContains(roles, userRole) {
5959
valid = false
6060
break
6161
}

0 commit comments

Comments
 (0)