Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fcc-get-projects edge function #1

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/production.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/staging.yaml

This file was deleted.

10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.idea
.vscode
./jest/node_modules/*
./config-tool/node_modules
.env
./node_modules/*
node_modules
.DS_Store
.DS_STore
.env
.vscode

4 changes: 4 additions & 0 deletions hold/.env.january-event
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SUPABASE_HOST=https://hnoejachzqwtzdovwljj.supabase.co
SUPABASE_SERVICE_KEY=<key>
SHARED_PASSWORD=$Workshop!2023
PROFESSOR_GROUP_ID='f918b2f8-f587-4ee1-9f2d-35b3aed0b1e6'
96 changes: 96 additions & 0 deletions hold/create-users-from-csv.js
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 2 additions & 0 deletions hold/invites.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

[email protected]
Loading