File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,17 @@ const (
17
17
UserTypeDefault UserType = "default"
18
18
)
19
19
20
+ // LastLogin represents a LastLogin object
21
+ type LastLogin struct {
22
+ LoginDatetime * time.Time `json:"-"`
23
+ Status string `json:"status"`
24
+ }
25
+
20
26
// User represents a User object
21
27
type User struct {
22
28
Username string `json:"username"`
23
29
Email string `json:"email"`
30
+ LastLogin * LastLogin `json:"last_login"`
24
31
UserType UserType `json:"user_type"`
25
32
Restricted bool `json:"restricted"`
26
33
TFAEnabled bool `json:"tfa_enabled"`
@@ -42,6 +49,26 @@ type UserUpdateOptions struct {
42
49
Restricted * bool `json:"restricted,omitempty"`
43
50
}
44
51
52
+ // UnmarshalJSON implements the json.Unmarshaler interface
53
+ func (ll * LastLogin ) UnmarshalJSON (b []byte ) error {
54
+ type Mask LastLogin
55
+
56
+ p := struct {
57
+ * Mask
58
+ LoginDatetime * parseabletime.ParseableTime `json:"login_datetime"`
59
+ }{
60
+ Mask : (* Mask )(ll ),
61
+ }
62
+
63
+ if err := json .Unmarshal (b , & p ); err != nil {
64
+ return err
65
+ }
66
+
67
+ ll .LoginDatetime = (* time .Time )(p .LoginDatetime )
68
+
69
+ return nil
70
+ }
71
+
45
72
// UnmarshalJSON implements the json.Unmarshaler interface
46
73
func (i * User ) UnmarshalJSON (b []byte ) error {
47
74
type Mask User
You can’t perform that action at this time.
0 commit comments