diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Errors.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Errors.kt
index 27d1a529..462fa7a4 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Errors.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Errors.kt
@@ -123,6 +123,7 @@ const val ERROR_LIBRUS_API_MAINTENANCE = 181
const val ERROR_LIBRUS_PORTAL_MAINTENANCE = 182
const val ERROR_LIBRUS_API_NOTICEBOARD_PROBLEM = 183
const val ERROR_LOGIN_LIBRUS_PORTAL_CSRF_EXPIRED = 184
+const val ERROR_LIBRUS_API_DEVICE_REGISTERED = 185
const val ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN = 201
const val ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD = 202
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/Librus.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/Librus.kt
index b5438bd1..0a1ed593 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/Librus.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/Librus.kt
@@ -199,7 +199,6 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
ERROR_LOGIN_LIBRUS_MESSAGES_NO_SESSION_ID -> {
login()
}
- // TODO PORTAL CAPTCHA
ERROR_LIBRUS_API_TIMETABLE_NOT_PUBLIC -> {
data.timetableNotPublic = true
data()
@@ -208,6 +207,11 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
ERROR_LIBRUS_API_NOTES_NOT_ACTIVE -> {
data()
}
+ ERROR_LIBRUS_API_DEVICE_REGISTERED -> {
+ data.app.config.sync.tokenLibrusList =
+ data.app.config.sync.tokenLibrusList + data.profileId
+ data()
+ }
else -> callback.onError(apiError)
}
}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt
index 7a536c81..507c438f 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt
@@ -44,6 +44,8 @@ open class LibrusApi(open val data: DataLibrus, open val lastSync: Long?) {
.withResponse(response))
return
}
+ /*
+{"Status":"Error","Code":"DeviceRegistered","Message":"This device is alerdy registered.","Resources":{"..":{"Url":"https:\/\/api.librus.pl\/2.0\/Root"}},"Url":"https:\/\/api.librus.pl\/2.0\/ChangeRegister"}*/
val error = if (response?.code() == 200) null else
json.getString("Code") ?:
json.getString("Message") ?:
@@ -64,6 +66,7 @@ open class LibrusApi(open val data: DataLibrus, open val lastSync: Long?) {
"InvalidRequest" -> ERROR_LIBRUS_API_INVALID_REQUEST_PARAMS
"Nieprawidłowy węzeł." -> ERROR_LIBRUS_API_INCORRECT_ENDPOINT
"NoticeboardProblem" -> ERROR_LIBRUS_API_NOTICEBOARD_PROBLEM
+ "DeviceRegistered" -> ERROR_LIBRUS_API_DEVICE_REGISTERED
else -> ERROR_LIBRUS_API_OTHER
}.let { errorCode ->
if (errorCode !in ignoreErrors) {
@@ -115,6 +118,7 @@ open class LibrusApi(open val data: DataLibrus, open val lastSync: Long?) {
.allowErrorCode(HTTP_FORBIDDEN)
.allowErrorCode(HTTP_UNAUTHORIZED)
.allowErrorCode(HTTP_UNAVAILABLE)
+ .allowErrorCode(HTTP_NOT_FOUND)
.callback(callback)
.build()
.enqueue()
diff --git a/app/src/main/res/values/errors.xml b/app/src/main/res/values/errors.xml
index 126300bd..c69c7c99 100644
--- a/app/src/main/res/values/errors.xml
+++ b/app/src/main/res/values/errors.xml
@@ -95,6 +95,7 @@
ERROR_LIBRUS_PORTAL_MAINTENANCE
ERROR_LIBRUS_API_NOTICEBOARD_PROBLEM
ERROR_LOGIN_LIBRUS_PORTAL_CSRF_EXPIRED
+ ERROR_LIBRUS_API_DEVICE_REGISTERED
ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN
ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD
@@ -266,6 +267,7 @@
Librus Portal: przerwa techniczna
Wystąpił problem z tablicą ogłoszeń
Librus: Sesja logowania wygasła. Zaloguj się ponownie.
+ Urządzenie jest już zarejestrowane
Nieprawidłowy login lub hasło
Podano stare hasło