Browse Source

writeup: that ought to be good enough for a first draft

master
eta 2 years ago
parent
commit
890854ceda
  1. 7
      ircd-users.lisp
  2. 2174
      writeup/NEA writeup.lyx

7
ircd-users.lisp

@ -2,6 +2,7 @@
(defun register-user (username plaintext-password email)
"Registers a user with a given USERNAME, PLAINTEXT-PASSWORD and EMAIL, returning the ID of the new user created."
(declare (type string username plaintext-password email))
(unless (scan *username-regex* username)
(error "Username contains invalid characters."))
(pomo:with-transaction ()
@ -17,12 +18,14 @@
(defun password-to-bytes (password)
"Converts the string PASSWORD to UTF-8 bytes."
(declare (type string password))
(babel:string-to-octets password
:encoding :utf-8))
(defun change-user-password (uid password)
"Changes the password of the user with id UID to PASSWORD.
Raises an error if that user doesn't exist."
(declare (type integer uid) (type string password))
(let* ((password (password-to-bytes password))
(pw-string (ironclad:pbkdf2-hash-password-to-combined-string password)))
(execute-one (:update 'local_users
@ -33,6 +36,7 @@ Raises an error if that user doesn't exist."
(defun check-user-credentials (username password)
"Checks whether USERNAME and PASSWORD can be used to authenticate to a local user account.
If they authenticate successfully, returns the user ID; if they don't, returns NIL."
(declare (type string username password))
(let ((provided-pw (password-to-bytes password))
(user-info
(pomo:query (:select 'local_users.password 'users.id
@ -47,6 +51,7 @@ If they authenticate successfully, returns the user ID; if they don't, returns N
(defun get-user-device (uid device-name)
"Gets or creates a user device (called DEVICE-NAME) for the user with ID UID."
(declare (type integer uid) (type string device-name))
(pomo:with-logical-transaction ()
(let ((maybe-device
(pomo:query (:select 'id
@ -64,6 +69,7 @@ If they authenticate successfully, returns the user ID; if they don't, returns N
(defun get-user-source (uid)
"Gets an IRC message source for the user with ID UID."
(declare (type integer uid))
(let ((info (pomo:query (:select 'users.username 'users.server 'servers.domain
:from 'users
:inner-join 'servers :on (:= 'users.server 'servers.id)
@ -83,6 +89,7 @@ TARGET can be formatted like:
- user@domain.name (searches for `user' on server `domain.name')
- user|hex-id (where hex-id is a hexidecimal number representing a server's internal server ID; searches for `user' on that server)
- just an ordinary nickname (searches for that nickname on the local server)"
(declare (type string target))
(multiple-value-bind (nick-part host-part)
(split-string-at-first target #\@ t t)
(if (string-empty-p host-part)

2174
writeup/NEA writeup.lyx

File diff suppressed because it is too large
Loading…
Cancel
Save