From 8029fe9ab938660706da0e58073ef6cd72c44e85 Mon Sep 17 00:00:00 2001 From: Suraj Patil Date: Fri, 13 May 2016 13:53:23 +0530 Subject: [PATCH] added sign up feature & login works with new sign up --- main.go | 1 + sessions/sessions.go | 4 ++-- templates/login.html | 1 + views/otherViews.go | 20 ++++++++++++++++++++ views/sessionViews.go | 39 ++++++++++++++++++++++++--------------- 5 files changed, 48 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index 34f456b..3b2f04b 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,7 @@ func main() { //Login logout http.HandleFunc("/login/", views.LoginFunc) http.HandleFunc("/logout/", views.RequiresLogin(views.LogoutFunc)) + http.HandleFunc("/signup/", views.SignUpFunc) http.HandleFunc("/add-category/", views.RequiresLogin(views.AddCategoryFunc)) http.HandleFunc("/add-comment/", views.RequiresLogin(views.AddCommentFunc)) diff --git a/sessions/sessions.go b/sessions/sessions.go index be955c6..55c3960 100755 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -11,8 +11,8 @@ var Store = sessions.NewCookieStore([]byte("secret-password")) //IsLoggedIn will check if the user has an active session and return True func IsLoggedIn(r *http.Request) bool { - session, _ := Store.Get(r, "session") - if session.Values["loggedin"] == "true" { + session, err := Store.Get(r, "session") + if err == nil && (session.Values["loggedin"] == "true") { return true } return false diff --git a/templates/login.html b/templates/login.html index 47d3ae1..eeaf200 100644 --- a/templates/login.html +++ b/templates/login.html @@ -20,6 +20,7 @@
+