add missing error handling
This commit is contained in:
+11
-3
@@ -108,9 +108,13 @@ func Run(configPath *string, localDBPath *string) {
|
|||||||
// set uuid mapping in LDAPSessions
|
// set uuid mapping in LDAPSessions
|
||||||
UserSessions[uuid.String()] = &userbackends
|
UserSessions[uuid.String()] = &userbackends
|
||||||
// save the session
|
// save the session
|
||||||
session.Save()
|
err = session.Save()
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"auth": false})
|
||||||
|
} else {
|
||||||
// return successful auth
|
// return successful auth
|
||||||
c.JSON(http.StatusOK, gin.H{"auth": true})
|
c.JSON(http.StatusOK, gin.H{"auth": true})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.DELETE("/ticket", func(c *gin.Context) {
|
router.DELETE("/ticket", func(c *gin.Context) {
|
||||||
@@ -124,10 +128,14 @@ func Run(configPath *string, localDBPath *string) {
|
|||||||
uuid := SessionUUID.(string)
|
uuid := SessionUUID.(string)
|
||||||
|
|
||||||
// delete uuid entry from user sessions
|
// delete uuid entry from user sessions
|
||||||
delete(UserSessions, uuid)
|
delete(UserSessions, uuid) // deletes uuid mapping
|
||||||
session.Options(sessions.Options{MaxAge: -1}) // set max age to -1 so session cookie is deleted
|
session.Options(sessions.Options{MaxAge: -1}) // set max age to -1 so session cookie is deleted
|
||||||
session.Save()
|
err := session.Save() // if save somehow fails, it should be ok since the uuid mapping is already deleted
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"auth": false})
|
||||||
|
} else {
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{"auth": false})
|
c.JSON(http.StatusUnauthorized, gin.H{"auth": false})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.GET("/pools/:poolid", func(c *gin.Context) {
|
router.GET("/pools/:poolid", func(c *gin.Context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user