Handle public instances #126
@ -84,7 +84,7 @@ class ReaderActivity : AppCompatActivity(), DIAware {
|
||||
}
|
||||
|
||||
private fun readItem(item: SelfossModel.Item) {
|
||||
if (appSettingsService.isMarkOnScrollEnabled() and !appSettingsService.getPublicAccess()) {
|
||||
if (appSettingsService.isMarkOnScrollEnabled() && !appSettingsService.getPublicAccess()) {
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.markAsRead(item)
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class SelfossModel {
|
||||
fun getApiConfiguration() = configuration ?: ApiConfiguration(null, null)
|
||||
}
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
AmineB
commented
Can be changed to Can be changed to `@Serializable`
|
||||
data class ApiConfiguration(
|
||||
@Serializable(with = BooleanSerializer::class)
|
||||
val publicMode: Boolean?,
|
||||
|
@ -448,6 +448,9 @@ class Repository(
|
||||
if (fetchedInformation.data.getApiMajorVersion() != apiMajorVersion) {
|
||||
appSettingsService.updateApiVersion(fetchedInformation.data.getApiMajorVersion())
|
||||
}
|
||||
// Check if we're accessing the instance in public mode
|
||||
// This happens when auth and public mode are enabled but
|
||||
// no credentials are provided to login
|
||||
AmineB
commented
I didn't look into how public instances work, but this condition seems weird.
They seem to mean different things. I didn't look into how public instances work, but this condition seems weird.
`isAuthEnabled` and `isPublicModeEnabled` can be `true` at the same time ?
They seem to mean different things.
davidoskky
commented
Yes, it is the normal case in fact; the weird condition is actually Yes, it is the normal case in fact; the weird condition is actually `isAuthEnabled` `false` and `isPublicModeEnabled` `true`.
Authentication is enabled because the administrator user can log in and read/favourite articles or edit sources while everyone else can just read the articles (and not mark them as read). Having authentication disabled simply means that no password is required to access and thus everyone is administrator, in this case it would make no sense to enable public mode as well.
AmineB
commented
Can you please add this to a comment ? Can you please add this to a comment ?
|
||||
if (appSettingsService.getUserName().isEmpty()
|
||||
AmineB
commented
`appSettingsService.updatePublicAccess(fetchedInformation.data.getApiConfiguration().isPublicModeEnabled())` isn't enough ?
davidoskky
commented
No, public mode might be enabled but we could still log into the instance with username and password. No, public mode might be enabled but we could still log into the instance with username and password.
Public mode has limitations, thus if one had the credentials to access the instance, that would actually be the preferred option.
davidoskky
commented
I'll rectify to explain what I mean. In the settings I am not storing the remote value of the configuration, I am directly storing whether we connected through public mode or not; in this way in any point of the application in which this information is required, that'll be readily available without any further processing. That's because we could connect trough the normal authentication method even if public mode was enabled. I'll rectify to explain what I mean. In the settings I am not storing the remote value of the configuration, I am directly storing whether we connected through public mode or not; in this way in any point of the application in which this information is required, that'll be readily available without any further processing. That's because we could connect trough the normal authentication method even if public mode was enabled.
Alternatively, I'd have to store both values of the remote configuration: `isPublicModeEnabled` and `isAuthEnabled` and each time check if these imply that we're connecting through public mode.
Since we are not using these information for anything else, storing it would be redundant.
|
||||
&& fetchedInformation.data.getApiConfiguration().isAuthEnabled()
|
||||
&& fetchedInformation.data.getApiConfiguration().isPublicModeEnabled()) {
|
||||
|
and
should be changed to&&
.We do not care about the value of
appSettingsService.getPublicAccess()
ifappSettingsService.isMarkOnScrollEnabled()
is false.