Open chr15m opened 1 year ago
Need to package this up so it's available when Sitefox + nbb are installed.
(ns set-user-password (:require [applied-science.js-interop :as j] [promesa.core :as p] [sitefox.auth :refer [hash-password save-user]] [sitefox.db :refer [f]])) (defn change-password [password email] (p/let [users (f "users" (fn [u] (= (j/get-in u [:auth :email]) email))) user (first users) [hashed-password salt] (hash-password password) user (when user (j/assoc! user :auth (clj->js {:email email :password hashed-password :salt salt})))] (if user (save-user user) (print "User not found.\n" "Usage: set-user-password EMAIL NEW-PASSWORD")))) (change-password (.pop js/process.argv) (.pop js/process.argv))
Need to package this up so it's available when Sitefox + nbb are installed.