Skip to content

Commit 3d80ec7

Browse files
fix: use user.UpdatedTime as scim.Meta.Version instead of user.Id (casdoor#2406)
* 111 * fix: use user.UpdatedTime as scim.Meta.Version instead of user.Id --------- Co-authored-by: hsluoyz <[email protected]>
1 parent 43d8490 commit 3d80ec7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

scim/util.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ func buildExternalId(user *object.User) optional.String {
9696
func buildMeta(user *object.User) scim.Meta {
9797
createdTime := util.String2Time(user.CreatedTime)
9898
updatedTime := util.String2Time(user.UpdatedTime)
99+
if user.UpdatedTime == "" {
100+
updatedTime = createdTime
101+
}
99102
return scim.Meta{
100103
Created: &createdTime,
101104
LastModified: &updatedTime,
102-
Version: user.Id,
105+
Version: util.Time2String(updatedTime),
103106
}
104107
}
105108

util/time.go

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ func String2Time(timestamp string) time.Time {
5454
return parseTime
5555
}
5656

57+
func Time2String(timestamp time.Time) string {
58+
return timestamp.Format(time.RFC3339)
59+
}
60+
5761
func IsTokenExpired(createdTime string, expiresIn int) bool {
5862
createdTimeObj, _ := time.Parse(time.RFC3339, createdTime)
5963
expiresAtObj := createdTimeObj.Add(time.Duration(expiresIn) * time.Second)

0 commit comments

Comments
 (0)