wip(backend): More consistency in string names
This commit is contained in:
parent
53a0316b39
commit
3f3e316eb4
3 changed files with 6 additions and 20 deletions
|
@ -63,6 +63,7 @@ ApikeyModel.prototype.guardedRead = async function ({ params, user }) {
|
||||||
apikey: {
|
apikey: {
|
||||||
key: this.record.id,
|
key: this.record.id,
|
||||||
level: this.record.level,
|
level: this.record.level,
|
||||||
|
createdAt: this.record.createdAt,
|
||||||
expiresAt: this.record.expiresAt,
|
expiresAt: this.record.expiresAt,
|
||||||
name: this.record.name,
|
name: this.record.name,
|
||||||
userId: this.record.userId,
|
userId: this.record.userId,
|
||||||
|
@ -141,6 +142,7 @@ ApikeyModel.prototype.create = async function ({ body, user }) {
|
||||||
key: this.record.id,
|
key: this.record.id,
|
||||||
secret,
|
secret,
|
||||||
level: this.record.level,
|
level: this.record.level,
|
||||||
|
createdAt: this.record.createdAt,
|
||||||
expiresAt: this.record.expiresAt,
|
expiresAt: this.record.expiresAt,
|
||||||
name: this.record.name,
|
name: this.record.name,
|
||||||
userId: this.record.userId,
|
userId: this.record.userId,
|
||||||
|
|
|
@ -11,22 +11,6 @@ export function PatternModel(tools) {
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
data String
|
|
||||||
design String
|
|
||||||
img String?
|
|
||||||
person Person? @relation(fields: [personId], references: [id])
|
|
||||||
personId Int?
|
|
||||||
name String @default("")
|
|
||||||
notes String
|
|
||||||
public
|
|
||||||
settings String
|
|
||||||
user User @relation(fields: [userId], references: [id])
|
|
||||||
userId Int
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
*/
|
|
||||||
|
|
||||||
PatternModel.prototype.guardedCreate = async function ({ body, user }) {
|
PatternModel.prototype.guardedCreate = async function ({ body, user }) {
|
||||||
if (user.level < 3) return this.setResponse(403, 'insufficientAccessLevel')
|
if (user.level < 3) return this.setResponse(403, 'insufficientAccessLevel')
|
||||||
|
|
|
@ -265,7 +265,7 @@ UserModel.prototype.passwordLogin = async function (req) {
|
||||||
* Confirms a user account
|
* Confirms a user account
|
||||||
*/
|
*/
|
||||||
UserModel.prototype.confirm = async function ({ body, params }) {
|
UserModel.prototype.confirm = async function ({ body, params }) {
|
||||||
if (!params.id) return this.setResponse(404, 'missingConfirmationId')
|
if (!params.id) return this.setResponse(404, 'confirmationIdMissing')
|
||||||
if (Object.keys(body) < 1) return this.setResponse(400, 'postBodyMissing')
|
if (Object.keys(body) < 1) return this.setResponse(400, 'postBodyMissing')
|
||||||
if (!body.consent || typeof body.consent !== 'number' || body.consent < 1)
|
if (!body.consent || typeof body.consent !== 'number' || body.consent < 1)
|
||||||
return this.setResponse(400, 'consentRequired')
|
return this.setResponse(400, 'consentRequired')
|
||||||
|
@ -338,7 +338,7 @@ 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
|
// Control
|
||||||
if ([1, 2, 3, 4, 5].includes(body.control)) data.control = body.control
|
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()
|
||||||
|
@ -442,8 +442,8 @@ UserModel.prototype.guardedMfaUpdate = async function ({ body, user, ip }) {
|
||||||
|
|
||||||
// Disable
|
// Disable
|
||||||
if (body.mfa === false) {
|
if (body.mfa === false) {
|
||||||
if (!body.token) return this.setResponse(400, 'mfaTokenRequired')
|
if (!body.token) return this.setResponse(400, 'mfaTokenMissing')
|
||||||
if (!body.password) return this.setResponse(400, 'passwordRequired')
|
if (!body.password) return this.setResponse(400, 'passwordMissing')
|
||||||
// Check password
|
// Check password
|
||||||
const [valid] = verifyPassword(body.password, this.record.password)
|
const [valid] = verifyPassword(body.password, this.record.password)
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue