wip(backend): Added control to account
This commit is contained in:
parent
ea885e4e7e
commit
772cf4ffdf
5 changed files with 31 additions and 26 deletions
|
@ -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
|
||||
|
|
Binary file not shown.
|
@ -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,
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue