-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: private users can remove app lock even after team enforce (#2240) (
#2241) * fix: app lock can be changes when enforced and it is cleared when not enforced * add docs Co-authored-by: Mohamad Jaara <[email protected]> Co-authored-by: Oussama Hassine <[email protected]>
- Loading branch information
1 parent
7893659
commit d0d84c0
Showing
11 changed files
with
80 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/IsAppLockEditableUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.featureConfig | ||
|
||
import com.wire.kalium.logic.data.session.SessionRepository | ||
import com.wire.kalium.logic.feature.UserSessionScopeProvider | ||
import com.wire.kalium.logic.functional.fold | ||
|
||
/** | ||
* Checks if the app lock is editable. | ||
* The app lock is editable if there is no enforced app lock on any of the user's accounts. | ||
* If there is an enforced app lock on any of the user's accounts, the app lock is not editable. | ||
*/ | ||
class IsAppLockEditableUseCase internal constructor( | ||
private val userSessionScopeProvider: UserSessionScopeProvider, | ||
private val sessionRepository: SessionRepository | ||
) { | ||
suspend operator fun invoke(): Boolean = | ||
sessionRepository.allValidSessions().fold({ | ||
true | ||
}) { accounts -> | ||
accounts.map { session -> | ||
userSessionScopeProvider.getOrCreate(session.userId).let { userSessionScope -> | ||
userSessionScope.userConfigRepository.isTeamAppLockEnabled().fold({ | ||
true | ||
}, { appLockConfig -> | ||
appLockConfig.isEnforced | ||
}) | ||
} | ||
}.contains(true).not() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters