Skip to content

Commit

Permalink
Rename accounts-enabling config variable
Browse files Browse the repository at this point in the history
  • Loading branch information
anbsky committed Jul 20, 2019
1 parent a692c44 commit 077ce5e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const testSetupWait = 200 * time.Millisecond

func TestMain(m *testing.M) {
// call flag.Parse() here if TestMain uses flags
config.Override("IsAccountV1Enabled", 1)
config.Override("AccountsEnabled", 1)
defer config.RestoreOverridden()

dbConfig := config.GetDatabase()
Expand Down
6 changes: 3 additions & 3 deletions api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"io/ioutil"
"net/http"

"github.com/lbryio/lbrytv/config"
"github.com/lbryio/lbrytv/internal/monitor"
"github.com/lbryio/lbrytv/app/player"
"github.com/lbryio/lbrytv/app/proxy"
"github.com/lbryio/lbrytv/app/users"
"github.com/lbryio/lbrytv/config"
"github.com/lbryio/lbrytv/internal/monitor"

"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -50,7 +50,7 @@ func Proxy(w http.ResponseWriter, req *http.Request) {
return
}

if config.IsAccountV1Enabled() {
if config.AccountsEnabled() {
accountID, err = users.GetAccountIDFromRequest(req)
if err != nil {
response, _ := json.Marshal(proxy.NewErrorResponse(err.Error(), proxy.ErrProxyAuthFailed))
Expand Down
10 changes: 5 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func (c *ConfigWrapper) Init() {
c.Viper.SetDefault("Host", "http://localhost:8080")
c.Viper.SetDefault("BaseContentURL", "http://localhost:8080/content/")

c.Viper.SetDefault("IsAccountV1Enabled", true)
c.Viper.SetDefault("AccountsEnabled", false)
c.Viper.BindEnv("AccountsEnabled")

c.Viper.SetConfigName("lbrytv") // name of config file (without extension)

Expand Down Expand Up @@ -117,10 +118,9 @@ func RestoreOverridden() {

// Concrete v variables go here

// IsAccountV1Enabled enables or disables Account Subsystem V1 (database + plain auth_token)
func IsAccountV1Enabled() bool {

return Config.Viper.GetBool("IsAccountV1Enabled")
// AccountsEnabled enables or disables accounts subsystem
func AccountsEnabled() bool {
return Config.Viper.GetBool("AccountsEnabled")
}

// GetAddress determines address to bind http API server to
Expand Down
2 changes: 1 addition & 1 deletion deployments/docker-dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
target: /static
environment:
LW_LBRYNET: http://lbrynet:5279/
LW_IsAccountV1Enabled: 1
LW_ACCOUNTSENABLED: 1
depends_on:
- lbrynet
- postgres
Expand Down
1 change: 1 addition & 0 deletions deployments/docker-production/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ services:
target: /static
environment:
LW_LBRYNET: http://lbrynet:5279/
LW_ACCOUNTSENABLED: 0
depends_on:
- lbrynet
- postgres
Expand Down
2 changes: 1 addition & 1 deletion deployments/docker/app/config/lbrytv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Database:
DBName: lbrytv
Options: sslmode=disable

IsAccountV1Enabled: 0
AccountsEnabled: 0
2 changes: 1 addition & 1 deletion lbrytv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Database:
DBName: lbrytv
Options: sslmode=disable

IsAccountV1Enabled: 1
AccountsEnabled: 0

0 comments on commit 077ce5e

Please sign in to comment.