mirror of
https://github.com/adanrsantos/ThePlaceHolders.git
synced 2024-12-16 08:00:39 -06:00
Fixed bug
This commit is contained in:
parent
dfc0702228
commit
8db276823b
22
users.go
22
users.go
|
@ -129,6 +129,7 @@ func (s *Server) handle_register(w http.ResponseWriter, r *http.Request) {
|
||||||
session.Values[SESSION_AUTH] = true
|
session.Values[SESSION_AUTH] = true
|
||||||
session.Values[SESSION_STARTED] = now.String()
|
session.Values[SESSION_STARTED] = now.String()
|
||||||
session.Values[SESSION_CONFIRMED] = false
|
session.Values[SESSION_CONFIRMED] = false
|
||||||
|
session.Values[SESSION_CONFIRM_KEY] = "asdf"
|
||||||
// Send session token to browser
|
// Send session token to browser
|
||||||
session.Save(r, w)
|
session.Save(r, w)
|
||||||
// Redirect to index.html
|
// Redirect to index.html
|
||||||
|
@ -140,18 +141,23 @@ func (s *Server) handle_register(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) handle_confirmation(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) handle_confirmation(w http.ResponseWriter, r *http.Request) {
|
||||||
|
session, err := s.Sessions.Get(r, SESSION_COOKIE_NAME)
|
||||||
|
if err != nil {
|
||||||
|
s.handle_logout(w, r)
|
||||||
|
http.Redirect(w, r, "/register", http.StatusFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
session, err := s.Sessions.Get(r, SESSION_COOKIE_NAME)
|
confirmed := session.Values[SESSION_CONFIRMED].(bool)
|
||||||
if err != nil {
|
fmt.Println("User email confirmed: ", confirmed)
|
||||||
s.handle_logout(w, r)
|
if confirmed {
|
||||||
http.Redirect(w, r, "/register", http.StatusFound)
|
http.Redirect(w, r, "/", http.StatusFound)
|
||||||
return
|
} else {
|
||||||
|
http.ServeFile(w, r, "./static/confirmation.html")
|
||||||
}
|
}
|
||||||
confirmed := session.Values[SESSION_CONFIRMED]
|
|
||||||
fmt.Println("Session confirmed: ", confirmed)
|
|
||||||
http.ServeFile(w, r, "./static/confirmation.html")
|
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
|
code := r.FormValue("code")
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue