chickadee » oauthtoothy » current-auth

current-authparameter

Current authentication state parameter containing user authentication details.

Unauthenticated state: ((authenticated? . #f))

Authenticated state structure:

  • authenticated?: boolean - #t if user is authenticated
  • provider-id: any - unique identifier for the user from the OAuth provider
  • Additional fields from the user-info-parser
;; Check authentication in route handlers
(get ("/protected")
     (let ((auth (current-auth)))
       (if (alist-ref 'authenticated? auth)
           (format "Welcome, ~A!" (alist-ref 'name auth))
           (redirect "/login"))))

;; Access user data
(let ((auth (current-auth)))
  (when (alist-ref 'authenticated? auth)
    (let ((provider-id (alist-ref 'provider-id auth))
          (email (alist-ref 'email auth)))
      ;; Process authenticated user...
      )))