Initial commit
This commit is contained in:
20
internal/controller/helper.go
Normal file
20
internal/controller/helper.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"photodisk/internal/auth"
|
||||
)
|
||||
|
||||
func SetUser(c *gin.Context, user auth.User) {
|
||||
c.Set("user", user)
|
||||
}
|
||||
|
||||
func GetUser(c *gin.Context) auth.User {
|
||||
user, ok := c.Get("user")
|
||||
if !ok {
|
||||
log.Fatal("user not found in context")
|
||||
}
|
||||
|
||||
return user.(auth.User)
|
||||
}
|
||||
Reference in New Issue
Block a user