mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 21:06:44 -06:00
[Api] Move FSLogin realms URL to GitHub sites.
This commit is contained in:
parent
891be2f9dd
commit
e6dec4c6c0
@ -367,8 +367,10 @@ class SzkolnyApi(val app: App) : CoroutineScope {
|
|||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun getRealms(registerName: String): List<LoginInfo.Platform> {
|
fun getRealms(registerName: String): List<LoginInfo.Platform> {
|
||||||
val response = api.fsLoginRealms(registerName).execute()
|
val response = api.fsLoginRealms(registerName).execute()
|
||||||
|
if (response.isSuccessful && response.body() != null) {
|
||||||
return parseResponse(response)
|
return response.body()!!
|
||||||
|
}
|
||||||
|
throw SzkolnyApiException(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
|
@ -39,6 +39,6 @@ interface SzkolnyService {
|
|||||||
@GET("registerAvailability")
|
@GET("registerAvailability")
|
||||||
fun registerAvailability(): Call<ApiResponse<Map<String, RegisterAvailabilityStatus>>>
|
fun registerAvailability(): Call<ApiResponse<Map<String, RegisterAvailabilityStatus>>>
|
||||||
|
|
||||||
@GET("fsLogin/{registerName}")
|
@GET("https://szkolny-eu.github.io/FSLogin/realms/{registerName}.json")
|
||||||
fun fsLoginRealms(@Path("registerName") registerName: String): Call<ApiResponse<List<LoginInfo.Platform>>>
|
fun fsLoginRealms(@Path("registerName") registerName: String): Call<List<LoginInfo.Platform>>
|
||||||
}
|
}
|
||||||
|
@ -12,25 +12,30 @@ import pl.szczodrzynski.edziennik.md5
|
|||||||
class ApiCacheInterceptor(val app: App) : Interceptor {
|
class ApiCacheInterceptor(val app: App) : Interceptor {
|
||||||
|
|
||||||
override fun intercept(chain: Interceptor.Chain): Response {
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
if (Signing.appCertificate.md5() == app.config.apiInvalidCert) {
|
val request = chain.request()
|
||||||
|
if (request.url().host() == "api.szkolny.eu"
|
||||||
|
&& Signing.appCertificate.md5() == app.config.apiInvalidCert
|
||||||
|
) {
|
||||||
val response = ApiResponse<Unit>(
|
val response = ApiResponse<Unit>(
|
||||||
success = false,
|
success = false,
|
||||||
errors = listOf(ApiResponse.Error("InvalidSignature", ""))
|
errors = listOf(ApiResponse.Error("InvalidSignature", ""))
|
||||||
)
|
)
|
||||||
|
|
||||||
return Response.Builder()
|
return Response.Builder()
|
||||||
.request(chain.request())
|
.request(request)
|
||||||
.protocol(Protocol.HTTP_1_1)
|
.protocol(Protocol.HTTP_1_1)
|
||||||
.code(401)
|
.code(401)
|
||||||
.message("Unauthorized")
|
.message("Unauthorized")
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.body(ResponseBody.create(
|
.body(
|
||||||
MediaType.parse("application/json"),
|
ResponseBody.create(
|
||||||
app.gson.toJson(response)
|
MediaType.parse("application/json"),
|
||||||
))
|
app.gson.toJson(response)
|
||||||
|
)
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
return chain.proceed(chain.request())
|
return chain.proceed(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user