diff --git a/components/connection/ServerConnectForm.vue b/components/connection/ServerConnectForm.vue
index f3a3470c..7e46a116 100644
--- a/components/connection/ServerConnectForm.vue
+++ b/components/connection/ServerConnectForm.vue
@@ -22,6 +22,9 @@
{{ $strings.MessageOldServerAuthWarning }}
{{ $strings.LabelMoreInfo }}
+
+
No server version set. Connect to update server config.
+
{{ $strings.ButtonAddNewServer }}
@@ -829,7 +832,7 @@ export default {
this.serverConfig.refreshToken = user.refreshToken
} else {
// Detect if the connection config is using the old token. If so, force re-login
- if (this.serverConfig.token === user.token) {
+ if (this.serverConfig.token === user.token || user.isOldToken) {
this.setForceReloginForNewAuth()
return
}
@@ -907,6 +910,7 @@ export default {
setForceReloginForNewAuth() {
this.error = this.$strings.MessageOldServerAuthReLoginRequired
this.showAuth = true
+ this.showForm = true
},
init() {
// Handle force re-login for servers using new JWT auth but still using an old token in the server config
diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift
index bd270f50..da344016 100644
--- a/ios/App/App/AppDelegate.swift
+++ b/ios/App/App/AppDelegate.swift
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.
let configuration = Realm.Configuration(
- schemaVersion: 19,
+ schemaVersion: 20,
migrationBlock: { [weak self] migration, oldSchemaVersion in
if (oldSchemaVersion < 1) {
self?.logger.log("Realm schema version was \(oldSchemaVersion)")
@@ -65,9 +65,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
self?.logger.log("Realm schema version was \(oldSchemaVersion)... Adding disableSleepTimerFadeOut settings")
migration.enumerateObjects(ofType: PlayerSettings.className()) { oldObject, newObject in
newObject?["disableSleepTimerFadeOut"] = false
- }
- }
-
+ }
+ }
+ if (oldSchemaVersion < 20) {
+ self?.logger.log("Realm schema version was \(oldSchemaVersion)... Adding version to ServerConnectionConfigs")
+ migration.enumerateObjects(ofType: ServerConnectionConfig.className()) { oldObject, newObject in
+ newObject?["version"] = ""
+ }
+ }
}
)
Realm.Configuration.defaultConfiguration = configuration
diff --git a/ios/App/App/plugins/AbsDatabase.swift b/ios/App/App/plugins/AbsDatabase.swift
index 8208be78..ca0749b4 100644
--- a/ios/App/App/plugins/AbsDatabase.swift
+++ b/ios/App/App/plugins/AbsDatabase.swift
@@ -53,11 +53,17 @@ public class AbsDatabase: CAPPlugin, CAPBridgedPlugin {
@objc func setCurrentServerConnectionConfig(_ call: CAPPluginCall) {
var id = call.getString("id")
let address = call.getString("address", "")
+ let version = call.getString("version", "")
let userId = call.getString("userId", "")
let username = call.getString("username", "")
let token = call.getString("token", "")
+ let refreshToken = call.getString("refreshToken", "") // Refresh only sent after login or refresh
let name = "\(address) (\(username))"
+
+ if (refreshToken != "") {
+ // TODO: Implement secure storage
+ }
if id == nil {
id = "\(address)@\(username)".toBase64()
@@ -68,6 +74,7 @@ public class AbsDatabase: CAPPlugin, CAPBridgedPlugin {
config.index = 0
config.name = name
config.address = address
+ config.version = version
config.userId = userId
config.username = username
config.token = token
@@ -82,6 +89,16 @@ public class AbsDatabase: CAPPlugin, CAPBridgedPlugin {
call.resolve()
}
+ @objc func getRefreshToken(_ call: CAPPluginCall) {
+ let serverConnectionConfigId = call.getString("serverConnectionConfigId", "")
+ // TODO: Implement secure storage
+ call.resolve()
+ }
+ @objc func clearRefreshToken(_ call: CAPPluginCall) {
+ let serverConnectionConfigId = call.getString("serverConnectionConfigId", "")
+ // TODO: Implement secure storage
+ call.resolve()
+ }
@objc func logout(_ call: CAPPluginCall) {
Store.serverConfig = nil
call.resolve()
diff --git a/ios/App/Shared/models/ServerConnectionConfig.swift b/ios/App/Shared/models/ServerConnectionConfig.swift
index be841da1..fea82e4b 100644
--- a/ios/App/Shared/models/ServerConnectionConfig.swift
+++ b/ios/App/Shared/models/ServerConnectionConfig.swift
@@ -13,6 +13,7 @@ class ServerConnectionConfig: Object {
@Persisted(indexed: true) var index: Int = 1
@Persisted var name: String = ""
@Persisted var address: String = ""
+ @Persisted var version: String = ""
@Persisted var userId: String = ""
@Persisted var username: String = ""
@Persisted var token: String = ""
@@ -29,6 +30,7 @@ func convertServerConnectionConfigToJSON(config: ServerConnectionConfig) -> Dict
"name": config.name,
"index": config.index,
"address": config.address,
+ "version": config.version,
"userId": config.userId,
"username": config.username,
"token": config.token,
diff --git a/ios/App/Shared/util/Database.swift b/ios/App/Shared/util/Database.swift
index c20a63b0..f40a57fe 100644
--- a/ios/App/Shared/util/Database.swift
+++ b/ios/App/Shared/util/Database.swift
@@ -27,6 +27,7 @@ class Database {
try existing.update {
existing.name = config.name
existing.address = config.address
+ existing.version = config.version
existing.userId = config.userId
existing.username = config.username
existing.token = config.token
diff --git a/layouts/default.vue b/layouts/default.vue
index 990da2c5..aa621721 100644
--- a/layouts/default.vue
+++ b/layouts/default.vue
@@ -154,9 +154,9 @@ export default {
if (this.$isValidVersion(serverSettings.version, '2.26.0')) {
// Check if the server is using the new JWT auth and is still using an old token in the server config
// If so, redirect to /connect and request to re-login
- if (serverConfig.token === user.token) {
+ if (serverConfig.token === user.token || user.isOldToken) {
this.attemptingConnection = false
- AbsLogger.info({ tag: 'default', message: `attemptConnection: Server is using new JWT auth but is still using an old token (server version: ${serverSettings.version}) (${serverConfig.name})` })
+ AbsLogger.info({ tag: 'default', message: `attemptConnection: Server is using new JWT auth but config is still using an old token (server version: ${serverSettings.version}) (${serverConfig.name})` })
// Clear last server config
await this.$store.dispatch('user/logout')
this.$router.push(`/connect?error=oldAuthToken&serverConnectionConfigId=${serverConfig.id}`)
diff --git a/strings/en-us.json b/strings/en-us.json
index e25c8e6c..fbd8e24a 100644
--- a/strings/en-us.json
+++ b/strings/en-us.json
@@ -325,7 +325,7 @@
"MessageNoSeries": "No series",
"MessageNoUpdatesWereNecessary": "No updates were necessary",
"MessageNoUserPlaylists": "You have no playlists",
- "MessageOldServerAuthReLoginRequired": "A new authentication system was added in server v2.26.0. Re-login is required for this server connection.",
+ "MessageOldServerAuthReLoginRequired": "A new authentication system was added in server v2.26.0. Please re-login to use the more secure authentication.",
"MessageOldServerAuthWarning": "Server is using out-dated authentication",
"MessageOldServerAuthWarningHelp": "Authentication was updated in server v2.26.0 to use a more secure method. A future app update will require server version v2.26.0 or higher. You will need to re-login after updating the server.",
"MessageOldServerConnectionWarning": "Server connection config is using an old user ID. Please delete and re-add this server connection.",