Vikunja now uses viper to handle config
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"encoding/hex"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/labstack/echo"
|
||||
"github.com/spf13/viper"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
@ -57,7 +58,7 @@ func Login(c echo.Context) error {
|
||||
claims["avatar"] = hex.EncodeToString(avatar[:])
|
||||
|
||||
// Generate encoded token and send it as response.
|
||||
t, err := token.SignedString(models.Config.JWTLoginSecret)
|
||||
t, err := token.SignedString([]byte(viper.GetString("service.JWTSecret")))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import (
|
||||
apiv1 "code.vikunja.io/api/routes/api/v1"
|
||||
_ "code.vikunja.io/api/routes/api/v1/swagger" // for docs generation
|
||||
"code.vikunja.io/api/routes/crud"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// NewEcho registers a new Echo instance
|
||||
@ -67,7 +68,7 @@ func RegisterRoutes(e *echo.Echo) {
|
||||
|
||||
// ===== Routes with Authetification =====
|
||||
// Authetification
|
||||
a.Use(middleware.JWT(models.Config.JWTLoginSecret))
|
||||
a.Use(middleware.JWT([]byte(viper.GetString("service.JWTSecret"))))
|
||||
a.POST("/tokenTest", apiv1.CheckToken)
|
||||
|
||||
listHandler := &crud.WebHandler{
|
||||
|
Reference in New Issue
Block a user