Welcome to the CHICKEN Scheme pasting service

awful login hack added by mario-goulart on Tue Oct 23 23:47:21 2012

(use awful http-session spiffy-cookies)

(define-app login
  matcher: identity
  parameters: ((enable-sxml #t))

  (define (define-my-page path content)
    (define-page path
      (lambda ()
        (sid (read-cookie (session-cookie-name)))
        (if (and (sid) (session-valid? (sid)))
            (content)
            (redirect-to (login-page-path))))))

  (define-my-page (main-page-path)
    (lambda ()
      '(p "Hi")))

  (define-page (login-page-path)
    (lambda ()
      (with-request-variables ((user (nonempty as-string))
                               (password (nonempty as-string)))
        (if (and user password (equal? user password)) ;; strong security
            (begin
              (sid (session-create))
              ((session-cookie-setter) (sid))
              (redirect-to (main-page-path)))
            `(form (@ (action "/login")
                      (method "post"))
                   (input (@ (type "text") (name "user")))
                   (input (@ (type "password") (name "password")))
                   (input (@ (type "submit")))))))
    method: '(GET POST))
  )

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which egg implements a Scheme to JavaScript compiler?
Visually impaired? Let me spell it for you (wav file) download WAV