mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-30 10:11:23 +02:00
fail to generate user tokens if no secret
This commit is contained in:
parent
6c3f99065a
commit
d1d762aa83
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user