feat: first successful login
This commit is contained in:
parent
e1b372a2a4
commit
28c56dd9c9
@ -3,7 +3,6 @@ S-DOM is a plugin for IntelliJ IDEA that allows you to submit your code to the D
|
|||||||
It is currently in development and not yet ready for use.
|
It is currently in development and not yet ready for use.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
- Fix ContentConvertException when trying to log in
|
|
||||||
- Implement submissions
|
- Implement submissions
|
||||||
- Implement reading results
|
- Implement reading results
|
||||||
- Implement reading problems (and testcases)
|
- Implement reading problems (and testcases)
|
||||||
|
@ -77,7 +77,11 @@ object SDom {
|
|||||||
|
|
||||||
suspend fun login(username: String, password: String, url: String) {
|
suspend fun login(username: String, password: String, url: String) {
|
||||||
val fixedApi = url.trimEnd('/') + "/v4/"
|
val fixedApi = url.trimEnd('/') + "/v4/"
|
||||||
val result: SDLoginResult = client.get(url = Url(fixedApi + "user")).body()
|
val result: SDLoginResult = client.get {
|
||||||
|
basicAuth(username, password)
|
||||||
|
url(fixedApi + "user")
|
||||||
|
}.body()
|
||||||
|
|
||||||
if (!result.enabled) throw Exception("User is not enabled")
|
if (!result.enabled) throw Exception("User is not enabled")
|
||||||
SDCredentials.credentials = Pair(username, password)
|
SDCredentials.credentials = Pair(username, password)
|
||||||
SDCredentials.url = fixedApi
|
SDCredentials.url = fixedApi
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package io.gitlab.jfronny.sdom.model
|
package io.gitlab.jfronny.sdom.model
|
||||||
|
|
||||||
import kotlinx.datetime.LocalDateTime
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@ -5,18 +5,18 @@ import kotlinx.serialization.Serializable
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SDLoginResult(
|
data class SDLoginResult(
|
||||||
@SerialName("last_login_time") val lastLoginTime: String, // DateTime
|
@SerialName("last_login_time") val lastLoginTime: String?, // DateTime
|
||||||
@SerialName("last_api_login_time") val lastApiLoginTime: String, // DateTime
|
@SerialName("last_api_login_time") val lastApiLoginTime: String?, // DateTime
|
||||||
@SerialName("first_login_time") val firstLoginTime: String, // DateTime
|
@SerialName("first_login_time") val firstLoginTime: String?, // DateTime
|
||||||
val team: String,
|
val team: String?,
|
||||||
@SerialName("team_id") val teamId: Int,
|
@SerialName("team_id") val teamId: Int?,
|
||||||
val roles: List<String>,
|
val roles: List<String>,
|
||||||
val type: String,
|
val type: String?,
|
||||||
val id: String,
|
val id: String,
|
||||||
val username: String,
|
val username: String,
|
||||||
val name: String,
|
val name: String,
|
||||||
val email: String,
|
val email: String?,
|
||||||
@SerialName("last_ip") val lastIp: String,
|
@SerialName("last_ip") val lastIp: String?,
|
||||||
val ip: String,
|
val ip: String?,
|
||||||
val enabled: Boolean
|
val enabled: Boolean
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user