Skip to content

Commit

Permalink
Merge branch 'hotfix/app-driver' into 'main'
Browse files Browse the repository at this point in the history
修复应用多驱动时,鉴权失效多问题

See merge request goku/apinto!236
  • Loading branch information
刘健 committed Mar 17, 2023
2 parents c927f35 + 068e664 commit 8b0626f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions drivers/app/manager/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ func (a *AppData) All() []string {
a.locker.RLock()
defer a.locker.RUnlock()
idMap := make(map[string]bool)

for _, v := range a.data {
for _, id := range v {
if _, ok := idMap[id]; !ok {
idMap[id] = true
}
}
}

ids := make([]string, 0, len(idMap))
for key := range idMap {
ids = append(ids, key)
Expand Down
22 changes: 13 additions & 9 deletions drivers/app/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,21 @@ func (m *Manager) Set(app application.IApp, filters []application.IAuth, users m
}
idMap[filter.Driver()] = append(idMap[filter.Driver()], filter.ID())
}
idArr := make([]string, 0, len(idMap))
for driver, ids := range idMap {
old := m.appManager.GetByAppID(app.Id())
m.appManager.Set(app.Id(), driver, ids)
cs := compareArray(old, ids)
for id := range cs {
filter, has := m.Untyped.Get(id)
if has {
filter.Del(app.Id())
if filter.UserCount() == 0 {
m.Untyped.Del(id)
}
idArr = append(idArr, ids...)
}

// 比较新旧id,删除旧配置
old := m.appManager.GetByAppID(app.Id())
cs := compareArray(old, idArr)
for id := range cs {
filter, has := m.Untyped.Get(id)
if has {
filter.Del(app.Id())
if filter.UserCount() == 0 {
m.Untyped.Del(id)
}
}
}
Expand Down

0 comments on commit 8b0626f

Please sign in to comment.