diff --git a/hold/.env.january-event b/hold/.env.january-event new file mode 100644 index 0000000..6808de9 --- /dev/null +++ b/hold/.env.january-event @@ -0,0 +1,4 @@ +SUPABASE_HOST=https://hnoejachzqwtzdovwljj.supabase.co +SUPABASE_SERVICE_KEY='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imhub2VqYWNoenF3dHpkb3Z3bGpqIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTY5NDAxMDgwOSwiZXhwIjoyMDA5NTg2ODA5fQ.nbC4-g2vraSZRJCyfyTzuvRMSBp-O7N_eO4k-J6A95A' +SHARED_PASSWORD=$Workshop!2023 +PROFESSOR_GROUP_ID='f918b2f8-f587-4ee1-9f2d-35b3aed0b1e6' \ No newline at end of file diff --git a/hold/create-users-from-csv.js b/hold/create-users-from-csv.js new file mode 100644 index 0000000..849290a --- /dev/null +++ b/hold/create-users-from-csv.js @@ -0,0 +1,96 @@ +const Supa = require('@supabase/supabase-js'); +const commandLineArgs = require('command-line-args'); +const fs = require('fs'); +const stream = require('stream'); +const assert = require('assert'); + +const main = async (options) => { + let supabase = Supa.createClient( + process.env.SUPABASE_HOST, + process.env.SUPABASE_SERVICE_KEY, + { + auth: { + persistSession: false, + autoRefreshToken: false, + detectSessionInUrl: false, + }, + } + ); + + const orgProfessorGroupResp = await supabase + .from('organization_groups') + .select() + .eq('id', process.env.PROFESSOR_GROUP_ID); + + let str; + try { + str = fs.readFileSync(options.file, 'utf8'); + } catch (err) { + console.error(err); + return; + } + + const arr = str.split(/\r?\n/); + + console.log(arr); + + for (let i = 0; i < arr.length; i++) { + const username = arr[i]; + if (username.length > 0) { + supabase = Supa.createClient( + process.env.SUPABASE_HOST, + process.env.SUPABASE_SERVICE_KEY, + { + auth: { persistSession: false }, + } + ); + + const resp = await supabase.auth.admin.createUser({ + email: username, + password: process.env.SHARED_PASSWORD, + }); + + if (!resp.error) { + console.log(`Login successfully created for user ${username}`); + + let supabase = Supa.createClient( + process.env.SUPABASE_HOST, + process.env.SUPABASE_SERVICE_KEY, + { + auth: { + persistSession: false, + autoRefreshToken: false, + detectSessionInUrl: false, + }, + } + ); + + const profile = await supabase + .from('profiles') + .select() + .eq('email', username); + + // Add her to the Org Professors group + const groupUserResp = await supabase.from('group_users').insert({ + type_id: orgProfessorGroupResp.data[0].id, + user_id: profile.data[0].id, + group_type: 'organization', + }); + + assert(groupUserResp.error === null); + + console.log(`User ${username} added to Org Professor Group`); + } else { + console.error( + `Unable to create user: ${username}, error: ${resp.error}` + ); + } + } + } +}; + +const optionDefinitions = [{ name: 'file', alias: 'f', type: String }]; + +const options = commandLineArgs(optionDefinitions); + +main(options); diff --git a/hold/invites.csv b/hold/invites.csv new file mode 100644 index 0000000..0dd1c2c --- /dev/null +++ b/hold/invites.csv @@ -0,0 +1,2 @@ + +anindita@performantsoftware.com \ No newline at end of file diff --git a/supabase/functions/fcc-process-document-updates/index.ts b/supabase/functions/fcc-process-document-updates/index.ts new file mode 100644 index 0000000..e69de29