1
0
Fork 0

wip(backend): Added control to account

This commit is contained in:
joostdecock 2022-11-14 18:45:45 +01:00
parent ea885e4e7e
commit 772cf4ffdf
5 changed files with 31 additions and 26 deletions

View file

@ -43,6 +43,7 @@ model User {
bio String @default("") bio String @default("")
confirmations Confirmation[] confirmations Confirmation[]
consent Int @default(0) consent Int @default(0)
control Int @default(1)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
ehash String @unique ehash String @unique
email String email String
@ -69,10 +70,12 @@ model User {
model Pattern { model Pattern {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
createdAt DateTime @default(now()) createdAt DateTime @default(now())
data String? data String
design String
img String? img String?
person Person? @relation(fields: [personId], references: [id]) person Person? @relation(fields: [personId], references: [id])
personId Int? personId Int?
notes String
user User @relation(fields: [userId], references: [id]) user User @relation(fields: [userId], references: [id])
userId Int userId Int
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt

Binary file not shown.

View file

@ -328,6 +328,8 @@ UserModel.prototype.guardedUpdate = async function ({ body, user }) {
if (typeof body.bio === 'string') data.bio = body.bio if (typeof body.bio === 'string') data.bio = body.bio
// Consent // Consent
if ([0, 1, 2, 3].includes(body.consent)) data.consent = body.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 // Github
if (typeof body.github === 'string') data.github = body.github.split('@').pop() if (typeof body.github === 'string') data.github = body.github.split('@').pop()
// Imperial // Imperial
@ -426,6 +428,7 @@ UserModel.prototype.asAccount = function () {
id: this.record.id, id: this.record.id,
bio: this.clear.bio, bio: this.clear.bio,
consent: this.record.consent, consent: this.record.consent,
control: this.record.control,
createdAt: this.record.createdAt, createdAt: this.record.createdAt,
data: this.clear.data, data: this.clear.data,
email: this.clear.email, email: this.clear.email,

View file

@ -5,6 +5,7 @@ export const accountTests = async (chai, config, expect, store) => {
jwt: { jwt: {
bio: "I know it sounds funny but I just can't stand the pain", bio: "I know it sounds funny but I just can't stand the pain",
consent: 1, consent: 1,
control: 4,
github: 'sorchanidhubhghaill', github: 'sorchanidhubhghaill',
imperial: true, imperial: true,
language: 'es', language: 'es',
@ -13,6 +14,7 @@ export const accountTests = async (chai, config, expect, store) => {
key: { key: {
bio: "It's a long way to the top, if you wanna rock & roll", bio: "It's a long way to the top, if you wanna rock & roll",
consent: 2, consent: 2,
control: 3,
github: 'joostdecock', github: 'joostdecock',
imperial: true, imperial: true,
language: 'de', language: 'de',

View file

@ -311,31 +311,28 @@ export const personTests = async (chai, config, expect, store) => {
}) })
}) })
//it(`${store.icon( it(`${store.icon('person', auth)} Should clone a person (${auth})`, (done) => {
// 'person', chai
// auth .request(config.api)
//)} Should clone a person (${auth})`, (done) => { .post(`/people/${store.person[auth].id}/clone/${auth}`)
// chai .set(
// .request(config.api) 'Authorization',
// .post(`/people/${store.person[auth].id}/clone/${auth}`) auth === 'jwt'
// .set( ? 'Bearer ' + store.account.token
// 'Authorization', : 'Basic ' +
// auth === 'jwt' new Buffer(`${store.account.apikey.key}:${store.account.apikey.secret}`).toString(
// ? 'Bearer ' + store.account.token 'base64'
// : 'Basic ' + )
// new Buffer( )
// `${store.account.apikey.key}:${store.account.apikey.secret}` .end((err, res) => {
// ).toString('base64') expect(err === null).to.equal(true)
// ) expect(res.status).to.equal(200)
// .end((err, res) => { expect(res.body.result).to.equal(`success`)
// expect(err === null).to.equal(true) expect(typeof res.body.error).to.equal(`undefined`)
// expect(res.status).to.equal(200) expect(typeof res.body.person.id).to.equal(`number`)
// expect(res.body.result).to.equal(`success`) done()
// expect(typeof res.body.error).to.equal(`undefined`) })
// expect(typeof res.body.person.id).to.equal(`number`) })
// done()
// })
//})
it(`${store.icon( it(`${store.icon(
'person', 'person',