mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Config: Add public flag to disable auth #16
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
@@ -55,3 +55,17 @@ func DeleteSession(router *gin.RouterGroup, conf *config.Config) {
|
||||
c.JSON(http.StatusOK, gin.H{"status": "ok", "token": token})
|
||||
})
|
||||
}
|
||||
|
||||
// Returns true, if user doesn't have a valid session token
|
||||
func Unauthorized(c *gin.Context, conf *config.Config) bool {
|
||||
if conf.Public() {
|
||||
return false
|
||||
}
|
||||
|
||||
token := c.GetHeader("X-Session-Token")
|
||||
gc := conf.Cache()
|
||||
|
||||
_, found := gc.Get(token)
|
||||
|
||||
return found
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user