Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. -- name: insert-player @single
  2. -- Inserts a new player into the database.
  3. INSERT INTO player (login, email, display_name, pass_hash, pass_salt)
  4. VALUES(:login, lower(:email), :display_name,
  5. decode(:hash, 'hex'), decode(:salt, 'hex'))
  6. RETURNING player_id;
  7.  
  8.  
  9.  
  10. (defun add-player (login email display-name passphrase &optional activatep)
  11. "Adds the player with the provided data into the database and optionally
  12. activates them. Returns the newly created player's database ID."
  13. (check-type login string)
  14. (check-type email string)
  15. (check-type display-name string)
  16. (check-type passphrase string)
  17. ;; TODO remove password object from Gateway
  18. (multiple-value-bind (hash salt) (derive-key passphrase)
  19. (let ((id (gateway/sql:insert-player :login login :email email
  20. :display-name display-name
  21. :hash hash :salt salt)))
  22. (when activatep (activate-player :id id))))
  23. t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement