ref: ba6890796a49f14426feb3c57f82fbda5f53c8c0
parent: ad1e200c8cb361906fadbe310dfbdc2e8e606982
author: Michael Misch <michaelmisch1985@gmail.com>
date: Fri Nov 29 17:50:38 PST 2019
Use a please log in to continue page
--- a/TODO
+++ b/TODO
@@ -2,7 +2,13 @@
[ ] plugin/earn.go: URL encoding such as `?specialty=myspecialty&country=mycountry` add to map[string]interface{} sent to pages/earn.go
[ ] pages/earn.go: Internationalize data
[ ] templates/earn.tpl: Simple page layout
+[ ] db/search.go: Lookup based on query for price
+TODO (nemo, halfwit) partner.html - Become A Partner page
+[ ] general: design partner.html
+[ ] pages/partner.go: Pull data from partner.html for internationalization
+[ ] templates/partner.tpl: convert from html
+
TODO (nemo, halfwit) legal.html - articulating the legal policy
[ ] general: design legal.html
[ ] pages/legal.go: Pull data from legal.html for internationalization
@@ -22,21 +28,21 @@
TODO (nemo, halfwit) messages.html - message thread with other user
[ ] plugins/messages.go: URL encoding such as '?id=21987402180982098'
-[ ] plugins/messages.go: Use token to target specific message thread
+[ ] plugins/messages.go: Use token to target specific message thread from db
[ ] plugins/messages.go: Validate token matches with user ID
[ ] pages/messages.go: Boiler plate internationalization
[ ] templates/messages.tpl: convert from messages.html
TODO (halfwit) patient/symptoms.html
-[ ] plugins/symptoms.go: Validate user login
+[x] plugins/login.go: Validate user login
-TODO (halfwit) send email to client for form submission
+TODO (halfwit) send email to client for form submission after transaction completed
[ ] transactions/symptoms.go: Send URL encoded link via email and wait for authorized login to pages
TODO (halfwit) login.html - We want to redirect back to the inaccessible page after successful (re) login
-[ ] router/pages.go: On no "access" to page, redirect to login
-[ ] pages/login.go: Check map for "redirect" member. Remove After: struct member
-[ ] forms/login.go: Verify "redirect" is set and follow
+[x] router/pages.go: On no "access" to page, redirect to login
+[x] pages/login.go: Check map for "redirect" member. Remove After: struct member
+[x] forms/login.go: Verify "redirect" is set and follow
TODO (halfwit) doctor/bookings.html - Look up details of a specific booking from profile
[ ] plugins/bookings.go: URL encodidng such as '?id=1320984392184298'
@@ -81,4 +87,4 @@
TODO (halfwit) Update footer template
[ ] templates/footer.tpl: Update Call toll free
[ ] templates/footer.tpl: Update Email
-[ ] templates/footer.tpl: Link from "Become A Partner" to doctor/application.html
+[x] templates/footer.tpl: Link from "Become A Partner" to partner.html
--- a/plugins/password.go
+++ b/plugins/password.go
@@ -41,7 +41,6 @@
us.Set("token", db.NewToken())
return nil
}
-
return errors.New(p.Sprint("Invalid login"))
}
--- a/router/forms.go
+++ b/router/forms.go
@@ -27,10 +27,6 @@
formlist[f.Path+".html"] = f
}
-// We want do redo this logic top down instead
-// Set a message in the plugin itself as the return error message
-// And on error, use it
-
func parseform(p *Request, w http.ResponseWriter, r *http.Request) (*Form, []string) {
var errors []string
form, ok := formlist[p.path]
--- a/router/pages.go
+++ b/router/pages.go
@@ -3,6 +3,7 @@
import (
"bufio"
"bytes"
+ "errors"
"fmt"
"html/template"
"path"
@@ -82,7 +83,7 @@
return nil, fmt.Errorf("No such page: %s", p.path)
}
if uint8(p.role)&uint8(cache.Access) == 0 {
- return nil, fmt.Errorf("Unauthorized")
+ return nil, errors.New("Unauthorized")
}
r := cache.Data(p.printer)
r["css"] = cache.CSS
--- a/router/run.go
+++ b/router/run.go
@@ -100,6 +100,7 @@
session: us,
path: r.URL.Path[1:],
}
+
switch r.Method {
case "GET":
get(p, w)
@@ -111,7 +112,6 @@
func (d *handle) logout(w http.ResponseWriter, r *http.Request) {
d.manager.Destroy(w, r)
http.Redirect(w, r, "/index.html", 302)
-
}
func post(p *Request, us session.Session, w http.ResponseWriter, r *http.Request) {
@@ -140,6 +140,11 @@
default:
data, err = getdata(p, "guest")
}
+ if err != nil && err.Error() == "Unauthorized" {
+ p.Session().Set("redirect", p.path)
+ http.Redirect(w, p.Request(), "/login.html", 302)
+ return
+ }
if err != nil {
http.Error(w, "Service Unavailable", 503)
return
@@ -175,7 +180,12 @@
func (d *handle) profile(w http.ResponseWriter, r *http.Request) {
user, status, us, role := getUser(d, w, r)
if status == "false" {
- http.Error(w, "Unauthorized", 401)
+ http.Redirect(w, r, "/login.html", 302)
+ return
+ }
+ if rd, ok := us.Get("redirect").(string); ok {
+ us.Delete("redirect")
+ http.Redirect(w, r, "/"+rd, 302)
return
}
p := &Request{