|
@@ -245,6 +245,21 @@ func (m *SwitchableAccountPoolManager) GetPoolByID(uuid string) (*SwitchableAcco
|
|
|
return &targetPool, nil
|
|
|
}
|
|
|
|
|
|
+// Remove user from all switch pool, which should be called when a user is logged out or removed
|
|
|
+func (p *SwitchableAccountPoolManager) RemoveUserFromAllSwitchableAccountPool(username string) error {
|
|
|
+ allAccountPool, err := p.GetAllPools()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ for _, accountPool := range allAccountPool {
|
|
|
+ if accountPool.IsAccessibleBy(username) {
|
|
|
+ //aka this user is in the pool
|
|
|
+ accountPool.RemoveUser(username)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
Switachable Account Pool functions
|
|
|
*/
|
|
@@ -308,6 +323,19 @@ func (p *SwitchableAccountsPool) UpdateUserPoolAccountInfo(username string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// Remove a user from the pool
|
|
|
+func (p *SwitchableAccountsPool) RemoveUser(username string) {
|
|
|
+ newAccountList := []*SwitchableAccount{}
|
|
|
+ for _, acc := range p.Accounts {
|
|
|
+ if acc.Username != username {
|
|
|
+ newAccountList = append(newAccountList, acc)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ p.Accounts = newAccountList
|
|
|
+ p.Save()
|
|
|
+}
|
|
|
+
|
|
|
// Save changes of this pool to database
|
|
|
func (p *SwitchableAccountsPool) Save() {
|
|
|
p.parent.Database.Write("auth_acswitch", p.UUID, p)
|