Commit e87a07cb authored by amirouche's avatar amirouche

web: rename login to signin

parent 19f229be
......@@ -116,7 +116,7 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
(cond
((not query) (values #f #f))
((null? query) (values #f #f))
((string=? (car query) "/login") (redirect "/login"))
((string=? (car query) "/signin") (redirect "/signin"))
((string=? (car query) "/signup") (redirect "/signup"))))
(define (index request)
......@@ -140,13 +140,13 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
(define sxml->response render-html)
(define (login/get request)
(define (signin/get request)
(sxml->response
(template "login"
(template "signin"
`(form (@ (method "POST"))
(h2 "Log in")
(p (label "login")
(input (@ (name "login")
(p (label "signin")
(input (@ (name "signin")
(type "text"))))
(p (label "password")
(input (@ (name "password")
......@@ -155,7 +155,7 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
(input (@ (type "submit")
(value "submit"))))))))
(define (login/post request body)
(define (signin/post request body)
...)
(define (maybe-error error)
......@@ -174,7 +174,7 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
(loop (cdr alist) out)))))
(define (signup/template errors)
(let ((login-error (assoc-ref errors "login"))
(let ((signin-error (assoc-ref errors "signin"))
(password-error (assoc-ref errors "password"))
(confirmation-error (assoc-ref errors "confirmation")))
(template "signup"
......@@ -184,11 +184,11 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
(background . (hsla 200 50 50 1))))))
(h2 "Sign up")
(div (@ (class ,(make-class `(("form-item" . #t)
("error" . ,login-error)))))
(p (label "login")
(input (@ (name "login")
("error" . ,signin-error)))))
(p (label "signin")
(input (@ (name "signin")
(type "text"))))
,(maybe-error login-error))
,(maybe-error signin-error))
(div (@ (class ,(make-class `(("form-item" . #t)
("error" . ,password-error)))))
(p (label "password")
......@@ -207,14 +207,14 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
(define (signup/get request)
(sxml->response (signup/template '())))
(define (login-valid? login)
(and (eq? (string-length (car login)) 0)
(define (signin-valid? signin)
(and (eq? (string-length (car signin)) 0)
"Password must be at least one character"))
(define (password-valid? password)
#t) ;; TODO
(define %signup `(("login" . ,login-valid?)
(define %signup `(("signin" . ,signin-valid?)
("password" . ,password-valid?)))
(define (signup/post request body)
......@@ -227,8 +227,8 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
(define (handler request body)
(match (cons (request-method request) (request-path-components request))
('(GET) (index request))
('(GET "login") (login/get request))
('(POST "login") (login/post request post))
('(GET "signin") (signin/get request))
('(POST "signin") (signin/post request post))
('(GET "signup") (signup/get request))
('(POST "signup") (signup/post request body))
(('GET "static" path ...) (render-static-asset path))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment