Skip to content

Commit

Permalink
Version bump to 1.0.0 (15) and added e-mail whitelisting for @dimensi…
Browse files Browse the repository at this point in the history
…on.it
  • Loading branch information
s1g53gv committed Dec 18, 2023
1 parent 92998c5 commit 15edfc9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {
minSdkVersion 24
targetSdkVersion 33
versionCode code
versionName "0.1.0"
versionName "1.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
15 changes: 13 additions & 2 deletions app/src/main/java/it/bz/noi/community/oauth/AuthManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Tue Sep 28 07:39:37 UTC 2021
VERSION_CODE=14
VERSION_CODE=15

0 comments on commit 15edfc9

Please sign in to comment.