diff --git a/app/build.gradle b/app/build.gradle index 46ce64a..70efb95 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,8 +43,9 @@ dependencies { implementation 'com.google.dagger:dagger:2.28' kapt 'com.google.dagger:dagger-compiler:2.28' - implementation 'com.github.hseapp:HSECore-Android:0.5.3' - implementation 'com.github.hseapp:HseNetwork:1.0.1' + implementation 'com.github.hseapp:HseCore-Android:0.5.4' + implementation 'com.github.hseapp:HseNetwork-Android:1.0.3' + implementation project(":auth") } \ No newline at end of file diff --git a/auth/src/main/java/com/hse/auth/ui/accountmanager/AccountManagerViewModel.kt b/auth/src/main/java/com/hse/auth/ui/accountmanager/AccountManagerViewModel.kt index eb47e06..ff3f937 100644 --- a/auth/src/main/java/com/hse/auth/ui/accountmanager/AccountManagerViewModel.kt +++ b/auth/src/main/java/com/hse/auth/ui/accountmanager/AccountManagerViewModel.kt @@ -183,11 +183,12 @@ class AccountManagerViewModel @Inject constructor(val network: Network) : val accountData = UserAccountData( email = userEmail, accessToken = tokensResult.accessToken, - refreshToken = tokensResult.refreshToken!!, + refreshToken = tokensResult.refreshToken + ?: userAccountData.refreshToken, avatartUrl = meEntity.avatarUrl, fullName = meEntity.fullName, accessExpiresIn = DateTime().millis + tokensResult.accessExpiresIn * 1000, - refreshExpiresIn = DateTime().millis + tokensResult.refreshExpiresIn * 1000 + refreshExpiresIn = if (tokensResult.refreshToken != null) DateTime().millis + tokensResult.refreshExpiresIn * 1000 else userAccountData.refreshExpiresIn ) _userAccountLiveData.postValue(accountData) _loginWithSelectedAccount.postValue(accountData) diff --git a/auth/src/main/java/com/hse/auth/ui/credentials/WebViewCredentialsFragment.kt b/auth/src/main/java/com/hse/auth/ui/credentials/WebViewCredentialsFragment.kt index 2149c12..e0587fc 100644 --- a/auth/src/main/java/com/hse/auth/ui/credentials/WebViewCredentialsFragment.kt +++ b/auth/src/main/java/com/hse/auth/ui/credentials/WebViewCredentialsFragment.kt @@ -90,6 +90,11 @@ class WebViewCredentialsFragment : requireContext().getRedirectUri() ) } ?: run { + val isFirstAccount = + AccountManager.get(requireContext()) + .accounts + .find { it.type == getString(R.string.ru_hseid_acc_type) } == null + val uriBuilder = Uri.Builder() .scheme(AUTH_SCHEME) .authority(AUTH_BASE_URL) @@ -98,13 +103,17 @@ class WebViewCredentialsFragment : .appendPath(AUTH_PATH_AUTHORIZE) .appendQueryParameter(KEY_CLIENT_ID, context?.getClientId()) .appendQueryParameter(KEY_RESPONSE_TYPE, RESPONSE_TYPE) - .appendQueryParameter(AUTH_PROMPT, PROMPT) + .appendQueryParameter(KEY_REDIRECT_URI, context?.getRedirectUri()) arguments?.getParcelable(KEY_USER_ACCOUNT_DATA)?.let { uriBuilder.appendQueryParameter(AUTH_LOGIN_HINT, it.email) } + if (isFirstAccount.not()) { + uriBuilder.appendQueryParameter(AUTH_PROMPT, PROMPT) + } + val uri = uriBuilder.build() val builder = CustomTabsIntent.Builder()