func ShowModeHandler(request http.ResponseWriter, response *http.Request) { session := sessions.GetSession(response) user_id := session.Get("user_id") fmt.FPrintf("Calling ShowMode Use id session \n%s", spew.Sdump(user_id)) if user_id == nil { request.WriteHeader(403) http.Redirect(request, response, "/", 403) } else { http.Redirect(request, response, "/mode", 202) } }
func loginHandler(response http.ResponseWriter, request *http.Request) { email := request.FormValue("email") password := request.FormValue("password") session := sessions.GetSession(request) db := utilities.GetDB(request) user := new(models.User) err := user.Authenticate(db, email, password) fmt.FPrintf("Calling login User session \n%s", spew.Sdump(user_id)) if err == nil { session.Set("user_id", user.ID.Hex()) session.Set("user_company", user.Company) session.Set("user_email", user.Email) http.Redirect(response, request, "/display", 302) } else { http.Redirect(response, request, "/", 302) } }