Merge pull request #2249 from vector-im/feature/fga/hide_cross_signing_no_session

Feature/fga/hide cross signing no session
This commit is contained in:
ganfra 2020-10-12 17:57:29 +02:00 committed by GitHub
commit 5d59b445fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 14 deletions

View File

@ -19,6 +19,7 @@ Improvements 🙌:
- Implement "Jump to read receipt" and "Mention" actions on the room member profile screen - Implement "Jump to read receipt" and "Mention" actions on the room member profile screen
- Add Sygnal API implementation to test is Push are correctly received - Add Sygnal API implementation to test is Push are correctly received
- Add PushGateway API implementation to test if Push are correctly received - Add PushGateway API implementation to test if Push are correctly received
- Cross signing: shouldn't offer to verify with other session when there is not. (#2227)
Bugfix 🐛: Bugfix 🐛:
- Improve support for image/audio/video/file selection with intent changes (#1376) - Improve support for image/audio/video/file selection with intent changes (#1376)

View File

@ -76,7 +76,8 @@ data class VerificationBottomSheetViewState(
val userWantsToCancel: Boolean = false, val userWantsToCancel: Boolean = false,
val userThinkItsNotHim: Boolean = false, val userThinkItsNotHim: Boolean = false,
val quadSContainsSecrets: Boolean = true, val quadSContainsSecrets: Boolean = true,
val quadSHasBeenReset: Boolean = false val quadSHasBeenReset: Boolean = false,
val hasAnyOtherSession: Boolean = false
) : MvRxState ) : MvRxState
class VerificationBottomSheetViewModel @AssistedInject constructor( class VerificationBottomSheetViewModel @AssistedInject constructor(
@ -119,6 +120,12 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
session.cryptoService().verificationService().getExistingTransaction(args.otherUserId, it) as? QrCodeVerificationTransaction session.cryptoService().verificationService().getExistingTransaction(args.otherUserId, it) as? QrCodeVerificationTransaction
} }
val hasAnyOtherSession = session.cryptoService()
.getCryptoDeviceInfo(session.myUserId)
.any {
it.deviceId != session.sessionParams.deviceId
}
setState { setState {
copy( copy(
otherUserMxItem = userItem?.toMatrixItem(), otherUserMxItem = userItem?.toMatrixItem(),
@ -130,7 +137,8 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
roomId = args.roomId, roomId = args.roomId,
isMe = args.otherUserId == session.myUserId, isMe = args.otherUserId == session.myUserId,
currentDeviceCanCrossSign = session.cryptoService().crossSigningService().canCrossSign(), currentDeviceCanCrossSign = session.cryptoService().crossSigningService().canCrossSign(),
quadSContainsSecrets = session.sharedSecretStorageService.isRecoverySetup() quadSContainsSecrets = session.sharedSecretStorageService.isRecoverySetup(),
hasAnyOtherSession = hasAnyOtherSession
) )
} }

View File

@ -52,6 +52,7 @@ class VerificationRequestController @Inject constructor(
val matrixItem = viewState?.otherUserMxItem ?: return val matrixItem = viewState?.otherUserMxItem ?: return
if (state.selfVerificationMode) { if (state.selfVerificationMode) {
if (state.hasAnyOtherSession) {
bottomSheetVerificationNoticeItem { bottomSheetVerificationNoticeItem {
id("notice") id("notice")
notice(stringProvider.getString(R.string.verification_open_other_to_verify)) notice(stringProvider.getString(R.string.verification_open_other_to_verify))
@ -64,13 +65,19 @@ class VerificationRequestController @Inject constructor(
dividerItem { dividerItem {
id("sep") id("sep")
} }
}
if (state.quadSContainsSecrets) { if (state.quadSContainsSecrets) {
val subtitle = if (state.hasAnyOtherSession) {
stringProvider.getString(R.string.verification_use_passphrase)
} else {
null
}
bottomSheetVerificationActionItem { bottomSheetVerificationActionItem {
id("passphrase") id("passphrase")
title(stringProvider.getString(R.string.verification_cannot_access_other_session)) title(stringProvider.getString(R.string.verification_cannot_access_other_session))
titleColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary)) titleColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary))
subTitle(stringProvider.getString(R.string.verification_use_passphrase)) subTitle(subtitle)
iconRes(R.drawable.ic_arrow_right) iconRes(R.drawable.ic_arrow_right)
iconColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary)) iconColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary))
listener { listener?.onClickRecoverFromPassphrase() } listener { listener?.onClickRecoverFromPassphrase() }