change post to get request with header
This commit is contained in:
parent
2d98665f92
commit
6a56b03bf6
3 changed files with 12 additions and 25 deletions
|
@ -23,14 +23,14 @@ func (wp *Webpage) defineRoutes() {
|
|||
c.HTML(http.StatusOK, "register.tmpl", gin.H{"title": "Register"})
|
||||
})
|
||||
|
||||
wp.Router.POST("/user", func(c *gin.Context) {
|
||||
username, uExisting := c.GetPostForm("username")
|
||||
if uExisting == false || username == "" {
|
||||
c.JSON(400, gin.H{"message": "bad post form"})
|
||||
wp.Router.GET("/user", func(c *gin.Context) {
|
||||
username := c.Request.Header.Get("username")
|
||||
if username != "" {
|
||||
success := wp.Database.UserIsLoggedIn(username)
|
||||
c.JSON(200, gin.H{"logged_in": success, "username": username})
|
||||
return
|
||||
}
|
||||
success := wp.Database.UserIsLoggedIn(username)
|
||||
c.JSON(200, gin.H{"logged_in": success, "username": username})
|
||||
c.JSON(200, gin.H{"logged_in": false, "username": ""})
|
||||
})
|
||||
|
||||
wp.Router.POST("/logout", func(c *gin.Context) {
|
||||
|
|
Reference in a new issue