fix(go): delete user if archived;

This commit is contained in:
Vishal Dalwadi 2025-07-01 22:31:22 +05:30
parent b76a09e571
commit bd9a6f106a
3 changed files with 9 additions and 1 deletions

View file

@ -122,6 +122,12 @@ func syncUsers(idpUsers []idp.User) error {
filters := logic.GetServerSettings().UserFilters
for _, user := range idpUsers {
if user.AccountArchived {
// delete the user if it has been archived.
_ = logic.DeleteUser(user.Username)
continue
}
var found bool
for _, filter := range filters {
if strings.HasPrefix(user.Username, filter) {

View file

@ -63,7 +63,7 @@ func (g *Client) GetUsers() ([]idp.User, error) {
var retval []idp.User
err := g.service.Users.List().
Customer("my_customer").
Fields("users(id,primaryEmail,name,suspended)", "nextPageToken").
Fields("users(id,primaryEmail,name,suspended,archived)", "nextPageToken").
Pages(context.TODO(), func(users *admindir.Users) error {
for _, user := range users.Users {
retval = append(retval, idp.User{
@ -71,6 +71,7 @@ func (g *Client) GetUsers() ([]idp.User, error) {
Username: user.PrimaryEmail,
DisplayName: user.Name.FullName,
AccountDisabled: user.Suspended,
AccountArchived: user.Archived,
})
}

View file

@ -10,6 +10,7 @@ type User struct {
Username string
DisplayName string
AccountDisabled bool
AccountArchived bool
}
type Group struct {