From 15edfc98f8cf4e57dec9ae702a670fb3600d4afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolo=CC=80=20Tosi?= Date: Mon, 18 Dec 2023 11:40:05 +0100 Subject: [PATCH] Version bump to 1.0.0 (15) and added e-mail whitelisting for @dimension.it --- app/build.gradle | 2 +- .../java/it/bz/noi/community/oauth/AuthManager.kt | 15 +++++++++++++-- app/version.properties | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5c401612..9d95af03 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,7 +33,7 @@ android { minSdkVersion 24 targetSdkVersion 33 versionCode code - versionName "0.1.0" + versionName "1.0.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/it/bz/noi/community/oauth/AuthManager.kt b/app/src/main/java/it/bz/noi/community/oauth/AuthManager.kt index abec02a0..fe19506a 100644 --- a/app/src/main/java/it/bz/noi/community/oauth/AuthManager.kt +++ b/app/src/main/java/it/bz/noi/community/oauth/AuthManager.kt @@ -68,7 +68,13 @@ object AuthManager { RetrofitBuilder.communityApiService } + /** + * Check if the user has a valid email, that is if it is allowed to use the app. + */ private suspend fun AuthState.isEmailValid(): Boolean { + + fun String.isDimensionEmail() = endsWith("@dimension.it") + return try { val token = obtainFreshToken() ?: return false val mail: String = getUserInfo(token, obtainAuthServiceConfig()).let { res -> @@ -78,8 +84,13 @@ object AuthManager { null } }?.email ?: return false - val accounts = RetrofitBuilder.communityApiService.getContacts(token.bearer()).contacts - accounts.firstOrNull { + + if (mail.isDimensionEmail()) { + return true + } + + val contacts = RetrofitBuilder.communityApiService.getContacts(token.bearer()).contacts + contacts.firstOrNull { it.email == mail } != null } catch (ex: Exception) { diff --git a/app/version.properties b/app/version.properties index e50e44cb..3fc0bf0e 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,2 +1,2 @@ #Tue Sep 28 07:39:37 UTC 2021 -VERSION_CODE=14 +VERSION_CODE=15