-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: role, id 로컬 저장 및 따라 자동로그인 로직 추가
- Loading branch information
1 parent
224a5ac
commit e54db4a
Showing
13 changed files
with
102 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Store/DefaultTokenPreferenceDataSource.kt → ...token/DefaultTokenPreferenceDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...re/dataStore/TokenPreferenceDataSource.kt → ...aStore/token/TokenPreferenceDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../com/withpeace/withpeace/core/datastore/dataStore/user/DefaultUserPreferenceDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.withpeace.withpeace.core.datastore.dataStore.user | ||
|
||
import androidx.datastore.core.DataStore | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.edit | ||
import androidx.datastore.preferences.core.longPreferencesKey | ||
import androidx.datastore.preferences.core.stringPreferencesKey | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
import javax.inject.Named | ||
|
||
class DefaultUserPreferenceDataSource @Inject constructor( | ||
@Named("user") private val dataStore: DataStore<Preferences>, | ||
) : UserPreferenceDataSource { | ||
override val userId: Flow<Long?> = dataStore.data.map { preferences -> | ||
preferences[USER_ID] | ||
} | ||
override val userRole: Flow<String?> = dataStore.data.map { preferences -> | ||
preferences[USER_ROLE] | ||
} | ||
|
||
override suspend fun updateUserId(userId: Long) { | ||
dataStore.edit { preferences -> | ||
preferences[USER_ID] = userId | ||
} | ||
} | ||
|
||
override suspend fun updateUserRole(userRole: String) { | ||
dataStore.edit { preferences -> | ||
preferences[USER_ROLE] = userRole | ||
} | ||
} | ||
|
||
override suspend fun removeAll() { | ||
dataStore.edit { preferences -> | ||
preferences.clear() | ||
} | ||
} | ||
|
||
companion object { | ||
private val USER_ID = longPreferencesKey("USER_ID") | ||
private val USER_ROLE = stringPreferencesKey("USER_ROLE") | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...in/java/com/withpeace/withpeace/core/datastore/dataStore/user/UserPreferenceDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.withpeace.withpeace.core.datastore.dataStore.user | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface UserPreferenceDataSource { | ||
|
||
val userId: Flow<Long?> | ||
|
||
val userRole: Flow<String?> | ||
|
||
suspend fun updateUserId(userId: Long) | ||
|
||
suspend fun updateUserRole(userRole: String) | ||
suspend fun removeAll() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/IsLoginUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/interceptor/src/main/java/com/withpeace/withpeace/core/interceptor/InterceptorModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters