mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
Drop settings in PostToken -- it isn't needed
This commit is contained in:
parent
f9f2fdc2c8
commit
a5c62fc572
1 changed files with 1 additions and 17 deletions
|
@ -6,23 +6,15 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gin-gonic/gin/binding"
|
"github.com/gin-gonic/gin/binding"
|
||||||
|
|
||||||
"github.com/drone/drone/pkg/server/session"
|
|
||||||
common "github.com/drone/drone/pkg/types"
|
common "github.com/drone/drone/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// POST /api/user/tokens
|
// POST /api/user/tokens
|
||||||
func PostToken(c *gin.Context) {
|
func PostToken(c *gin.Context) {
|
||||||
settings := ToSettings(c)
|
sess := ToSession(c)
|
||||||
store := ToDatastore(c)
|
store := ToDatastore(c)
|
||||||
user := ToUser(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{}
|
in := &common.Token{}
|
||||||
if !c.BindWith(in, binding.JSON) {
|
if !c.BindWith(in, binding.JSON) {
|
||||||
return
|
return
|
||||||
|
@ -43,14 +35,6 @@ func PostToken(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var sess session.Session
|
|
||||||
val, _ := c.Get("session")
|
|
||||||
if val != nil {
|
|
||||||
sess = val.(session.Session)
|
|
||||||
} else {
|
|
||||||
sess = session.New(settings.Session)
|
|
||||||
}
|
|
||||||
|
|
||||||
jwt, err := sess.GenerateToken(token)
|
jwt, err := sess.GenerateToken(token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.Fail(400, err)
|
||||||
|
|
Loading…
Reference in a new issue