Skip to content
Snippets Groups Projects
Commit 03be4884 authored by bschuhm's avatar bschuhm
Browse files

Initialize gitLab object when in logging in with token

Fixes #316.
The issue was the gitLab object being null so hostNameVerifier was also null and finalHostName was not set
parent 4cdc3b24
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -46,6 +46,7 @@ import com.commit451.gitlab.ssl.X509Util
import com.commit451.teleprinter.Teleprinter
import okhttp3.Credentials
import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.HttpException
import retrofit2.Response
Loading
Loading
@@ -256,14 +257,21 @@ class LoginActivity : BaseActivity() {
 
override fun responseNonNullSuccess(userLogin: User) {
account.privateToken = userLogin.privateToken
loadUser()
loadUser(clientBuilder)
}
})
}
 
fun connectByToken() {
account.privateToken = textToken.text.toString()
loadUser()
val gitlabClientBuilder = OkHttpClientFactory.create(account, false)
if (BuildConfig.DEBUG) {
gitlabClientBuilder.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
}
gitLab = GitLabFactory.createGitLab(account, gitlabClientBuilder)
loadUser(gitlabClientBuilder)
}
 
fun loginWithPrivateToken() {
Loading
Loading
@@ -335,13 +343,13 @@ class LoginActivity : BaseActivity() {
}
}
 
fun loadUser() {
val gitlabClientBuilder = OkHttpClientFactory.create(account, false)
fun loadUser(gitlabClientBuilder: OkHttpClient.Builder) {
if (BuildConfig.DEBUG) {
gitlabClientBuilder.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
}
val gitLab = GitLabFactory.create(account, gitlabClientBuilder.build())
gitLab.getThisUser()
val gitLabService = GitLabFactory.create(account, gitlabClientBuilder.build())
gitLabService.getThisUser()
.setup(bindToLifecycle())
.subscribe(object : CustomResponseSingleObserver<User>() {
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment