Require authentication to participate in chat (#4762)
* feat(chat): require authentication to participate in chat * fix: it's pretty much impossible to bypass the auth requirement, addressing review feedback anyway * feat(chat): render chat text input as disabled if chat auth is required * Commit updated API documentation --------- Co-authored-by: Owncast <owncast@owncast.online>
This commit is contained in:
@@ -46,6 +46,7 @@ const (
|
||||
chatEstablishedUsersOnlyModeKey = "chat_established_users_only_mode"
|
||||
chatSpamProtectionEnabledKey = "chat_spam_protection_enabled"
|
||||
chatSlurFilterEnabledKey = "chat_slur_filter_enabled"
|
||||
chatRequireAuthenticationKey = "chat_require_authentication"
|
||||
notificationsEnabledKey = "notifications_enabled"
|
||||
discordConfigurationKey = "discord_configuration"
|
||||
browserPushConfigurationKey = "browser_push_configuration"
|
||||
|
||||
@@ -67,6 +67,8 @@ type ConfigRepository interface {
|
||||
GetChatSpamProtectionEnabled() bool
|
||||
SetChatSlurFilterEnabled(enabled bool) error
|
||||
GetChatSlurFilterEnabled() bool
|
||||
SetChatRequireAuthentication(enabled bool) error
|
||||
GetChatRequireAuthentication() bool
|
||||
GetExternalActions() []models.ExternalAction
|
||||
SetExternalActions(actions []models.ExternalAction) error
|
||||
SetCustomStyles(styles string) error
|
||||
|
||||
@@ -541,6 +541,21 @@ func (r *SqlConfigRepository) GetChatSlurFilterEnabled() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// SetChatRequireAuthentication will set if authentication is required for chat.
|
||||
func (r *SqlConfigRepository) SetChatRequireAuthentication(enabled bool) error {
|
||||
return r.datastore.SetBool(chatRequireAuthenticationKey, enabled)
|
||||
}
|
||||
|
||||
// GetChatRequireAuthentication will return if authentication is required for chat.
|
||||
func (r *SqlConfigRepository) GetChatRequireAuthentication() bool {
|
||||
enabled, err := r.datastore.GetBool(chatRequireAuthenticationKey)
|
||||
if err == nil {
|
||||
return enabled
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// GetExternalActions will return the registered external actions.
|
||||
func (r *SqlConfigRepository) GetExternalActions() []models.ExternalAction {
|
||||
configEntry, err := r.datastore.Get(externalActionsKey)
|
||||
|
||||
Reference in New Issue
Block a user