Авторизация, нерабочий чат
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user