mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
20 lines
364 B
Go
20 lines
364 B
Go
package controllers
|
|
|
|
import (
|
|
"github.com/crawlab-team/crawlab/core/constants"
|
|
"github.com/crawlab-team/crawlab/core/models/models"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func GetUserFromContext(c *gin.Context) (u *models.User) {
|
|
value, ok := c.Get(constants.UserContextKey)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
u, ok = value.(*models.User)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
return u
|
|
}
|