Skip to content

Commit bd9a6f1

Browse files
committed
fix(go): delete user if archived;
1 parent b76a09e commit bd9a6f1

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

pro/auth/sync.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ func syncUsers(idpUsers []idp.User) error {
122122
filters := logic.GetServerSettings().UserFilters
123123

124124
for _, user := range idpUsers {
125+
if user.AccountArchived {
126+
// delete the user if it has been archived.
127+
_ = logic.DeleteUser(user.Username)
128+
continue
129+
}
130+
125131
var found bool
126132
for _, filter := range filters {
127133
if strings.HasPrefix(user.Username, filter) {

pro/idp/google/google.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ func (g *Client) GetUsers() ([]idp.User, error) {
6363
var retval []idp.User
6464
err := g.service.Users.List().
6565
Customer("my_customer").
66-
Fields("users(id,primaryEmail,name,suspended)", "nextPageToken").
66+
Fields("users(id,primaryEmail,name,suspended,archived)", "nextPageToken").
6767
Pages(context.TODO(), func(users *admindir.Users) error {
6868
for _, user := range users.Users {
6969
retval = append(retval, idp.User{
7070
ID: user.Id,
7171
Username: user.PrimaryEmail,
7272
DisplayName: user.Name.FullName,
7373
AccountDisabled: user.Suspended,
74+
AccountArchived: user.Archived,
7475
})
7576
}
7677

pro/idp/idp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type User struct {
1010
Username string
1111
DisplayName string
1212
AccountDisabled bool
13+
AccountArchived bool
1314
}
1415

1516
type Group struct {

0 commit comments

Comments
 (0)