// SPDX-License-Identifier: GPL-3.0-or-later // MyIce Kotlin Multiplatform — schedule/convocation viewer // Copyright (C) 2026 parano.ch // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package ch.parano.myicek.auth import ch.parano.myicek.network.AuthTokenHolder import com.russhwolf.settings.Settings class AuthSettings(private val settings: Settings) { companion object { private const val TOKEN_KEY = "access_token" private const val ACCOUNT_KEY = "selected_account" } fun getStoredToken(): String? = settings.getStringOrNull(TOKEN_KEY) fun setToken(token: String?) { if (token != null) { settings.putString(TOKEN_KEY, token) } else { settings.remove(TOKEN_KEY) } AuthTokenHolder.token = token } fun getStoredAccount(): String? = settings.getStringOrNull(ACCOUNT_KEY) fun setAccount(account: String) { settings.putString(ACCOUNT_KEY, account) } fun clear() { settings.remove(TOKEN_KEY) settings.remove(ACCOUNT_KEY) AuthTokenHolder.token = null } }