Beispiel #1
0
func Logout(c *gin.Context) {

	session := sessions.Get(c)
	session.DriverId = 0
	session.Handle = ""
	session.Save(c)
	c.Redirect(http.StatusMovedPermanently, "/")
}
Beispiel #2
0
func Hello(c *gin.Context) {

	session := sessions.Get(c)
	if session.IsLoggedIn() {
		c.Redirect(http.StatusMovedPermanently, "/dashboard")
		return
	}

	content := utils.Render("templates/index.tmpl", gin.H{"handle": session.Handle, "loggedIn": false})
	c.HTML(http.StatusOK, "master.tmpl", gin.H{"content": template.HTML(content)})
}
Beispiel #3
0
func AuthRequired(c *gin.Context) {

	// before request, make sure we have a session
	// and that they have a handle
	session := sessions.Get(c)

	if !session.IsLoggedIn() {
		utils.Log("Nobody logged in, going to login screen.")
		c.Redirect(http.StatusMovedPermanently, "/")
		return
	}

	c.Next()

	// after request
}
Beispiel #4
0
func Dashboard(c *gin.Context) {
	session := sessions.Get(c)
	content := utils.Render("templates/dashboard.tmpl", gin.H{"handle": session.Handle, "client_id": config.ClientId()})
	c.HTML(http.StatusOK, "master.tmpl", gin.H{"content": template.HTML(content)})
}