Skip to content

Commit a715d21

Browse files
authored
Merge pull request #156 from android/fix-sign-out
Remove invalid signout() instances
2 parents c99ee17 + 5457b72 commit a715d21

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

Shrine/app/src/main/java/com/authentication/shrine/repository/AuthRepository.kt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ class AuthRepository @Inject constructor(
9999
prefs[USERNAME] = username
100100
response.getSessionId()?.also {
101101
prefs[SESSION_ID] = it
102-
} ?: run {
103-
signOut()
104102
}
105103
}
106104
return true
@@ -124,8 +122,6 @@ class AuthRepository @Inject constructor(
124122
prefs[USERNAME] = username
125123
response.getSessionId()?.also {
126124
prefs[SESSION_ID] = it
127-
} ?: run {
128-
signOut()
129125
}
130126
}
131127
setSessionWithPassword(password)
@@ -156,8 +152,6 @@ class AuthRepository @Inject constructor(
156152
prefs[USERNAME] = response.body()?.username.orEmpty()
157153
response.getSessionId()?.also {
158154
prefs[SESSION_ID] = it
159-
} ?: run {
160-
signOut()
161155
}
162156
}
163157
return true
@@ -168,10 +162,7 @@ class AuthRepository @Inject constructor(
168162
Log.e(TAG, "Invalid login credentials", e)
169163

170164
// Remove previously stored credentials and start login over again
171-
dataStore.edit { prefs ->
172-
prefs.remove(USERNAME)
173-
prefs.remove(SESSION_ID)
174-
}
165+
signOut()
175166
}
176167
} else {
177168
Log.e(TAG, "Please check if username and session id is present in your datastore")
@@ -208,8 +199,6 @@ class AuthRepository @Inject constructor(
208199
dataStore.edit { prefs ->
209200
response.getSessionId()?.also {
210201
prefs[SESSION_ID] = it
211-
} ?: run {
212-
signOut()
213202
}
214203
}
215204
return response.getJsonObject()
@@ -300,8 +289,6 @@ class AuthRepository @Inject constructor(
300289
dataStore.edit { prefs ->
301290
response.getSessionId()?.also {
302291
prefs[SESSION_ID] = it
303-
} ?: run {
304-
signOut()
305292
}
306293
}
307294
return response.getJsonObject()

0 commit comments

Comments
 (0)