Skip to content

Commit f16e18a

Browse files
author
Piotr Andruszkiewicz
committed
Refactor user type handling in UnmarshalStatus: replace string literals with constants for clarity
1 parent 8731f68 commit f16e18a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pkg/user/status.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ import (
77
"github.com/wttech/aemc/pkg/common/fmtx"
88
)
99

10+
const (
11+
// Repository user types (as stored in JCR)
12+
RepUserType = "rep:User"
13+
RepSystemUserType = "rep:SystemUser"
14+
15+
// Maped user types
16+
UserType = "user"
17+
SystemUserType = "systemUser"
18+
)
19+
1020
type Status struct {
1121
Type string `json:"jcr:primaryType"`
1222
AuthorizableID string `json:"rep:authorizableId"`
@@ -22,10 +32,10 @@ func UnmarshalStatus(readCloser io.ReadCloser) (*Status, error) {
2232
}
2333

2434
switch status.Type {
25-
case "rep:User":
26-
status.Type = "user"
27-
case "rep:SystemUser":
28-
status.Type = "systemUser"
35+
case RepUserType:
36+
status.Type = UserType
37+
case RepSystemUserType:
38+
status.Type = SystemUserType
2939
default:
3040
return nil, fmt.Errorf("unknown user type: %s", status.Type)
3141
}

0 commit comments

Comments
 (0)