Skip to content

Commit

Permalink
fix addHacker to work with new user/hacker backend changes again
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanWilms committed Apr 22, 2019
1 parent 3000b42 commit 0162942
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/client/temp/AddHackers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,30 @@ const statuses = [
'Confirmed',
'Rejected',
];
const genders = ['Male', 'Female', 'Other', 'PreferNotToSay'];

const shirtSizes = ['UXS', 'US', 'UM', 'UL', 'UXL', 'UXXL', 'WS', 'WM', 'WL', 'WXL', 'WXXL'];

export const addHackers = (die: boolean) => {
if (die) {
for (let i = 0; i < 1000; i += 1) {
const fn = names[getRandom(21000)];
const ln = names[getRandom(21000)];
const bool = !!getRandom(2);
const status = statuses[getRandom(7)];
fetch('/api/register/hacker', {
body: JSON.stringify({
username: `${fn}.${ln}@gmail.com`,
firstName: fn,
gender: genders[getRandom(7)],
gradYear: getRandom(4) + 2019,
lastName: ln,
needsReimbursement: bool,
password: 'P@ssword1',
school: institutions[getRandom(1430)],
status: statuses[getRandom(7)],
shirtSize: shirtSizes[getRandom(11)],
status,
teamName: '',
username: `${fn}.${ln}@gmail.com`,
}),
headers: {
'Content-Type': 'application/json',
Expand All @@ -123,7 +129,7 @@ export const addHackers = (die: boolean) => {
hackers.forEach(hacker => {
const { email, ...rest } = hacker;
return fetch('/api/register/hacker', {
body: JSON.stringify({ ...rest, username: email, password: 'p@ssword1' }),
body: JSON.stringify({ ...rest, password: 'p@ssword1', username: email }),
headers: {
'Content-Type': 'application/json',
},
Expand Down
3 changes: 3 additions & 0 deletions src/server/api/UserRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ userRouter.post('/api/register/hacker', async (ctx, next) => {
email: createdUser.email,
status: ctx.request.body.status ? ctx.request.body.status : Status.Created,
user: createdUser._id,
school: ctx.request.body.school,
gradYear: ctx.request.body.gradYear,
needsReimbursement: ctx.request.body.needsReimbursement,
});
if (createdHacker) {
ctx.body = {
Expand Down

0 comments on commit 0162942

Please sign in to comment.