Skip to content

Commit

Permalink
Merge pull request #5 from hseapp/feature/HSEOAPI-20
Browse files Browse the repository at this point in the history
Hot fixes
  • Loading branch information
RomanAnchugov authored Oct 4, 2020
2 parents 1f81f83 + 77101b7 commit 46958e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<UserAccountData>(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()
Expand Down

0 comments on commit 46958e9

Please sign in to comment.