This is the code that runs https://bandolier.learnjsthehardway.com/ for you to review. It uses the https://git.learnjsthehardway.com/learn-javascript-the-hard-way/bandolier-template to create the documentation for the project.
https://bandolier.learnjsthehardway.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
547 B
16 lines
547 B
2 years ago
|
import crypto from "crypto";
|
||
|
import { User, UNSUB_CODE_SIZE } from "../lib/models.js";
|
||
|
import { knex } from "../lib/ormish.js";
|
||
|
|
||
|
export const description = "Updates users with no unsubkey, which can happen sometimes when manually adding people.";
|
||
|
|
||
|
export const main = async () => {
|
||
|
for(let u of await User.all({unsubscribe: false, unsubkey: ""})) {
|
||
|
const key = crypto.randomBytes(UNSUB_CODE_SIZE).toString("hex");
|
||
|
console.log(u.id, key, "length", key.length);
|
||
|
await User.update({id: u.id}, {unsubkey: key});
|
||
|
}
|
||
|
|
||
|
knex.destroy();
|
||
|
}
|