Changeset 625 in code for trunk/user.go


Ignore:
Timestamp:
Oct 12, 2021, 7:11:14 AM (4 years ago)
Author:
contact
Message:

service: allow updating other users

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user.go

    r612 r625  
    5959
    6060type eventStop struct{}
     61
     62type eventUserUpdate struct {
     63        password *string
     64        admin    *bool
     65        done     chan error
     66}
    6167
    6268type deliveredClientMap map[string]string // client name -> msg ID
     
    643649                                dc.SendMessage(msg)
    644650                        })
     651                case eventUserUpdate:
     652                        // copy the user record because we'll mutate it
     653                        record := u.User
     654
     655                        if e.password != nil {
     656                                record.Password = *e.password
     657                        }
     658                        if e.admin != nil {
     659                                record.Admin = *e.admin
     660                        }
     661
     662                        e.done <- u.updateUser(&record)
     663
     664                        // If the password was updated, kill all downstream connections to
     665                        // force them to re-authenticate with the new credentials.
     666                        if e.password != nil {
     667                                u.forEachDownstream(func(dc *downstreamConn) {
     668                                        dc.Close()
     669                                })
     670                        }
    645671                case eventStop:
    646672                        u.forEachDownstream(func(dc *downstreamConn) {
Note: See TracChangeset for help on using the changeset viewer.