Divia wrote:
> I'd like to set up email confirmation for my app (user signs up with
> an email address, receives an email with a link to click on to confirm
> that the email address actually belongs to the person who signed up),
> but I'm confused about how to do this with Weblocks.
Generating a confirmation code:
(defun confirmation-hash (email)
(sha1 (concatenate 'string email "salt")))
Installing a confirmation hash (substitute your own storage
mechanism for this):
(defvar *confirmation-hashes* (make-hash-table :test #'equalp))
(defun register-confirmation-hash (email hash)
(setf (gethash email *confirmation-hashes*) hash))
(defun confirmation-hash-correct-p (email hash)
(equalp (gethash email *confirmation-hashes*) hash))
Generating a confirmation link:
(defun make-confirmation-link (email)
(apply #'format nil "http://myhost/confirm-user/~A/~A"
(mapcar #'url-encode (list email (confirmation-hash email)))))
Installing a matching dispatcher (old nav system):
(defwidget top-navigation (navigation)
())
(defmethod selector-on-dispatch ((selector top-navigation) tokens)
(if (and (eql (length tokens) 3)
(equalp (first tokens "confirm-user")))
(let ((email (second tokens))
(hash (third tokens)))
(cond
((confirmation-hash-correct-p email hash)
(confirm-email email)
(values "You got it!" tokens nil))
(t
(values "Uh, sorry... :/" tokens nil))))
(call-next-method))) ; defer to static navigation
(defun init-user-session (root)
(setf (widget-children root)
(list (init-navigation (make-instance 'top-navigation :name "Main
nav")
...))))
Untested.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"weblocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/weblocks?hl=en
-~----------~----~----~----~------~----~------~--~---