New configuration system
This commit is contained in:
+2
-1
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
"github.com/deluan/gosonic/conf"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"github.com/deluan/gosonic/engine"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
@@ -40,7 +41,7 @@ func (c *BrowsingController) getArtistIndex(ifModifiedSince time.Time) responses
|
||||
}
|
||||
|
||||
res := responses.Indexes{
|
||||
IgnoredArticles: beego.AppConfig.String("ignoredArticles"),
|
||||
IgnoredArticles: conf.GoSonic.IgnoredArticles,
|
||||
LastModified: fmt.Sprint(utils.ToMillis(lastModified)),
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
"github.com/deluan/gosonic/conf"
|
||||
)
|
||||
|
||||
type ControllerInterface interface {
|
||||
@@ -17,7 +18,7 @@ type ControllerInterface interface {
|
||||
}
|
||||
|
||||
func Validate(controller BaseAPIController) {
|
||||
if beego.AppConfig.String("disableValidation") != "true" {
|
||||
if !conf.GoSonic.DisableValidation {
|
||||
checkParameters(controller)
|
||||
authenticate(controller)
|
||||
// TODO Validate version
|
||||
@@ -40,7 +41,7 @@ func checkParameters(c BaseAPIController) {
|
||||
}
|
||||
|
||||
func authenticate(c BaseAPIController) {
|
||||
password := beego.AppConfig.String("password")
|
||||
password := conf.GoSonic.Password
|
||||
user := c.GetString("u")
|
||||
pass := c.GetString("p")
|
||||
salt := c.GetString("s")
|
||||
@@ -61,7 +62,7 @@ func authenticate(c BaseAPIController) {
|
||||
valid = (t == token)
|
||||
}
|
||||
|
||||
if user != beego.AppConfig.String("user") || !valid {
|
||||
if user != conf.GoSonic.User || !valid {
|
||||
logWarn(c, fmt.Sprintf(`Invalid login for user "%s"`, user))
|
||||
abortRequest(c, responses.ErrorAuthenticationFail)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user