Skip to content
Snippets Groups Projects
Commit c0e79242 authored by John's avatar John
Browse files

Merge branch 'master' into 'master'

Initialize gitLab object when in logging in with token

Closes #316

See merge request Commit451/LabCoat!32
parents 4cdc3b24 03be4884
No related branches found
No related tags found
1 merge request!32Initialize gitLab object when in logging in with token
Pipeline #
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