Esempio n. 1
0
File: root.go Progetto: mssola/todo
// RootIndex renders the root page. It has three different options:
//
//  1. If there's no user, it renders the "Create user" page.
//  2. If the current user is not logged in, it render the "Login" page.
//  3. If the current user is logged in, then it redirects the user to the
//     /topics page.
func RootIndex(res http.ResponseWriter, req *http.Request) {
	id := lib.GetCookie(req, "userId")

	if id == nil {
		count := Count("users")
		if count == 0 {
			lib.Render(res, "users/new", lib.DefaultViewData())
		} else {
			lib.Render(res, "application/login", lib.DefaultViewData())
		}
	} else {
		http.Redirect(res, req, "/topics", http.StatusFound)
	}
}
Esempio n. 2
0
func license(w http.ResponseWriter, req *http.Request) {
	lib.Render(w, "application/license", lib.DefaultViewData())
}