Авторизация, нерабочий чат

This commit is contained in:
Халимов Рустам
2026-04-14 01:41:51 +03:00
parent 1fb1be47dd
commit dc051fa9ae
22 changed files with 160 additions and 49 deletions

View File

@@ -20,15 +20,23 @@ class TokenManager @Inject constructor(context: Context) {
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
fun saveToken(token: String) {
prefs.edit().putString("jwt_token", token).apply()
fun saveToken(token: String, userId: String? = null) {
val editor = prefs.edit().putString("jwt_token", token)
if (userId != null) {
editor.putString("user_id", userId)
}
editor.apply()
}
fun getToken(): String? {
return prefs.getString("jwt_token", null)
}
fun getUserId(): String? {
return prefs.getString("user_id", null)
}
fun deleteToken() {
prefs.edit().remove("jwt_token").apply()
prefs.edit().remove("jwt_token").remove("user_id").apply()
}
}