Skip to content

Commit a6d9332

Browse files
committed
chore: rename misleading method
The REST client doesn't do any authentication but rather retrieves the user and build info - the user is already authenticated via the API token. So `authenticate` is misleading here.
1 parent 5dfbdca commit a6d9332

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class CoderRemoteProvider(
346346
// Show sign in page if we have not configured the client yet.
347347
if (client == null) {
348348
val errorBuffer = mutableListOf<Throwable>()
349-
// When coming back to the application, authenticate immediately.
349+
// When coming back to the application, initializeSession immediately.
350350
val autologin = shouldDoAutoLogin()
351351
context.secrets.lastToken.let { lastToken ->
352352
context.secrets.lastDeploymentURL.let { lastDeploymentURL ->

src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class CoderCLIManager(
203203
}
204204

205205
/**
206-
* Use the provided token to authenticate the CLI.
206+
* Use the provided token to initializeSession the CLI.
207207
*/
208208
fun login(token: String): String {
209209
logger.info("Storing CLI credentials in $coderConfigPath")

src/main/kotlin/com/coder/toolbox/sdk/CoderRestClient.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,11 @@ open class CoderRestClient(
131131
}
132132

133133
/**
134-
* Authenticate and load information about the current user and the build
135-
* version.
134+
* Load information about the current user and the build version.
136135
*
137136
* @throws [APIResponseException].
138137
*/
139-
suspend fun authenticate(): User {
138+
suspend fun initializeSession(): User {
140139
me = me()
141140
buildVersion = buildInfo().version
142141
return me
@@ -149,7 +148,12 @@ open class CoderRestClient(
149148
suspend fun me(): User {
150149
val userResponse = retroRestClient.me()
151150
if (!userResponse.isSuccessful) {
152-
throw APIResponseException("authenticate", url, userResponse.code(), userResponse.parseErrorBody(moshi))
151+
throw APIResponseException(
152+
"initializeSession",
153+
url,
154+
userResponse.code(),
155+
userResponse.parseErrorBody(moshi)
156+
)
153157
}
154158

155159
return userResponse.body()!!

src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ open class CoderProtocolHandler(
143143
if (settings.requireTokenAuth) token else null,
144144
PluginManager.pluginInfo.version
145145
)
146-
client.authenticate()
146+
client.initializeSession()
147147
return client
148148
}
149149

src/main/kotlin/com/coder/toolbox/views/ConnectStep.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ConnectStep(
8686
)
8787
// allows interleaving with the back/cancel action
8888
yield()
89-
client.authenticate()
89+
client.initializeSession()
9090
statusField.textState.update { (context.i18n.ptrl("Checking Coder binary...")) }
9191
val cli = ensureCLI(context, client.url, client.buildVersion)
9292
// We only need to log in if we are using token-based auth.

0 commit comments

Comments
 (0)