diff --git a/sites/backend/prisma/schema.prisma b/sites/backend/prisma/schema.prisma index bd9b9e5178f..3dddd3e74c8 100644 --- a/sites/backend/prisma/schema.prisma +++ b/sites/backend/prisma/schema.prisma @@ -43,6 +43,7 @@ model User { bio String @default("") confirmations Confirmation[] consent Int @default(0) + control Int @default(1) createdAt DateTime @default(now()) ehash String @unique email String @@ -69,10 +70,12 @@ model User { model Pattern { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) - data String? + data String + design String img String? person Person? @relation(fields: [personId], references: [id]) personId Int? + notes String user User @relation(fields: [userId], references: [id]) userId Int updatedAt DateTime @updatedAt diff --git a/sites/backend/prisma/schema.sqlite b/sites/backend/prisma/schema.sqlite index 3b70180f5d1..939ff2b1eda 100644 Binary files a/sites/backend/prisma/schema.sqlite and b/sites/backend/prisma/schema.sqlite differ diff --git a/sites/backend/src/models/user.mjs b/sites/backend/src/models/user.mjs index 4baa556d9af..9deb4127f22 100644 --- a/sites/backend/src/models/user.mjs +++ b/sites/backend/src/models/user.mjs @@ -328,6 +328,8 @@ UserModel.prototype.guardedUpdate = async function ({ body, user }) { if (typeof body.bio === 'string') data.bio = body.bio // Consent if ([0, 1, 2, 3].includes(body.consent)) data.consent = body.consent + // Consent + if ([1, 2, 3, 4, 5].includes(body.control)) data.control = body.control // Github if (typeof body.github === 'string') data.github = body.github.split('@').pop() // Imperial @@ -426,6 +428,7 @@ UserModel.prototype.asAccount = function () { id: this.record.id, bio: this.clear.bio, consent: this.record.consent, + control: this.record.control, createdAt: this.record.createdAt, data: this.clear.data, email: this.clear.email, diff --git a/sites/backend/tests/account.mjs b/sites/backend/tests/account.mjs index ddf8dc36366..c8aa9d02f62 100644 --- a/sites/backend/tests/account.mjs +++ b/sites/backend/tests/account.mjs @@ -5,6 +5,7 @@ export const accountTests = async (chai, config, expect, store) => { jwt: { bio: "I know it sounds funny but I just can't stand the pain", consent: 1, + control: 4, github: 'sorchanidhubhghaill', imperial: true, language: 'es', @@ -13,6 +14,7 @@ export const accountTests = async (chai, config, expect, store) => { key: { bio: "It's a long way to the top, if you wanna rock & roll", consent: 2, + control: 3, github: 'joostdecock', imperial: true, language: 'de', diff --git a/sites/backend/tests/person.mjs b/sites/backend/tests/person.mjs index 84060c2a82d..cf6bc29bd64 100644 --- a/sites/backend/tests/person.mjs +++ b/sites/backend/tests/person.mjs @@ -311,31 +311,28 @@ export const personTests = async (chai, config, expect, store) => { }) }) - //it(`${store.icon( - // 'person', - // auth - //)} Should clone a person (${auth})`, (done) => { - // chai - // .request(config.api) - // .post(`/people/${store.person[auth].id}/clone/${auth}`) - // .set( - // 'Authorization', - // auth === 'jwt' - // ? 'Bearer ' + store.account.token - // : 'Basic ' + - // new Buffer( - // `${store.account.apikey.key}:${store.account.apikey.secret}` - // ).toString('base64') - // ) - // .end((err, res) => { - // expect(err === null).to.equal(true) - // expect(res.status).to.equal(200) - // expect(res.body.result).to.equal(`success`) - // expect(typeof res.body.error).to.equal(`undefined`) - // expect(typeof res.body.person.id).to.equal(`number`) - // done() - // }) - //}) + it(`${store.icon('person', auth)} Should clone a person (${auth})`, (done) => { + chai + .request(config.api) + .post(`/people/${store.person[auth].id}/clone/${auth}`) + .set( + 'Authorization', + auth === 'jwt' + ? 'Bearer ' + store.account.token + : 'Basic ' + + new Buffer(`${store.account.apikey.key}:${store.account.apikey.secret}`).toString( + 'base64' + ) + ) + .end((err, res) => { + expect(err === null).to.equal(true) + expect(res.status).to.equal(200) + expect(res.body.result).to.equal(`success`) + expect(typeof res.body.error).to.equal(`undefined`) + expect(typeof res.body.person.id).to.equal(`number`) + done() + }) + }) it(`${store.icon( 'person',