fail to generate user tokens if no secret

This commit is contained in:
Brad Rydzewski 2015-04-13 18:43:21 -07:00
parent 6c3f99065a
commit d1d762aa83

View file

@ -1,6 +1,7 @@
package server
import (
"errors"
"time"
"github.com/gin-gonic/gin"
@ -11,10 +12,18 @@ import (
// POST /api/user/tokens
func PostToken(c *gin.Context) {
settings := ToSettings(c)
store := ToDatastore(c)
sess := ToSession(c)
user := ToUser(c)
// if a session secret is not defined there is no way to
// generate jwt user tokens, so we must throw an error
if settings.Session == nil || len(settings.Session.Secret) == 0 {
c.String(500, "User tokens are not configured")
return
}
in := &common.Token{}
if !c.BindWith(in, binding.JSON) {
return