Exemplo n.º 1
0
func redirectAuthenticationPageForAdmin(c *revel.Controller) revel.Result {
	uidStr := c.Session["uid"]
	uid, _ := strconv.Atoi(uidStr)
	errorPage := c.RenderTemplate("errors/401.html")
	if len(uidStr) == 0 {
		return errorPage
	}
	if (models.User{}.FetchUserByUserId(uint(uid)).Status != models.UserAdmin) {
		return errorPage
	}
	return nil
}