Skip to content

Instantly share code, notes, and snippets.

@goloroden
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goloroden/59513a3e455083cb7a1a to your computer and use it in GitHub Desktop.
Save goloroden/59513a3e455083cb7a1a to your computer and use it in GitHub Desktop.
(defparameter *is-logged-in* nil)
(defparameter *users* '((golo secret)
(jones anothersecret)))
(defun user-by-login (login)
(assoc login *users*))
(defun password-of (user)
(cadr user))
(defun log-in (login password)
(let ((stored-password (password-of (user-by-login login))))
(when (equal stored-password password) (setf *is-logged-in* t))))
(defun log-out ()
(setf *is-logged-in* nil))
;; ----------------------------
> *is-logged-in*
NIL
> (log-in 'golo 'secret)
T
> *is-logged-in*
T
> (log-out)
NIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment