mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-01-23 06:38:34 +01:00
Reset default/active group when deleting a group
This commit is contained in:
parent
aa7321ce81
commit
bb76f851d8
@ -97,6 +97,25 @@ public function update(Group $group, array $data) : Group
|
||||
*/
|
||||
public function delete($ids) : int
|
||||
{
|
||||
$ids = is_array($ids) ? $ids : func_get_args();
|
||||
|
||||
// A group is possibly set as the default group in Settings.
|
||||
// In this case we reset the setting to "No group" (groupId = 0)
|
||||
$defaultGroupId = $this->settingService->get('defaultGroup');
|
||||
|
||||
if (in_array($defaultGroupId, $ids)) {
|
||||
$this->settingService->set('defaultGroup', 0);
|
||||
}
|
||||
|
||||
// A group is also possibly set as the active group if the user
|
||||
// configured 2FAuth to memorize the active group.
|
||||
// In this case we reset the setting to the pseudo "All" group (groupId = 0)
|
||||
$activeGroupId = $this->settingService->get('activeGroup');
|
||||
|
||||
if (in_array($activeGroupId, $ids)) {
|
||||
$this->settingService->set('activeGroup', 0);
|
||||
}
|
||||
|
||||
$deleted = Group::destroy($ids);
|
||||
|
||||
return $deleted;
|
||||
|
Loading…
Reference in New Issue
Block a user