Node.js based forum software built for the modern web
fix: user creation POST route returns user data, updated openapi spec
Julian Lambba2a4638cd1
diff --git a/openapi.yaml b/openapi.yamlindex cd39965319..58ef118d00 100644--- a/openapi.yaml+++ b/openapi.yaml@@ -160,6 +160,21 @@ components:userslug:type: stringexample: dragon-fruit+ email:+ type: string+ example: [email protected]+ email:confirmed:+ type: number+ example: 1+ joindate:+ type: number+ example: 1585337827953+ lastonline:+ type: number+ example: 1585337827953+ picture:+ type: string+ example: https://images.unsplash.com/photo-1560070094-e1f2ddec4337?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=256&h=256&q=80fullname:type: stringexample: Mr. Dragon Fruit Jr.@@ -184,64 +199,72 @@ components:example: |This is an example signatureIt can span multiple lines.- groupTitle:- type: string- example: "[\"administrators\",\"Staff\"]"uploadedpicture:type: stringexample: /assets/profile/1-profileimg.pngdescription: In almost all cases, defer to "picture" instead. Use this if you need to specifically reference the picture uploaded to the forum.- cover:url:- type: string- example: /assets/profile/1-cover.png- cover:position:- type: string- example: 50.0301% 19.2464%- picture:- type: string- example: https://images.unsplash.com/photo-1560070094-e1f2ddec4337?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=256&h=256&q=80- status:- type: string- example: online- postcount:- type: number- example: 1000- topiccount:- type: number- example: 50- followercount:- type: number- example: 2- followingcount:- type: number- example: 5profileviews:type: numberexample: 1000reputation:type: numberexample: 100- email:- type: string- example: [email protected]- email:confirmed:+ postcount:type: number- example: 1- lastonline:+ example: 1000+ topiccount:type: number- example: 1585337827953+ example: 50lastposttime:type: numberexample: 1585337827953- flags:- type: number- example: 0banned:type: numberexample: 0banned:expire:type: numberexample: 1585337827953- joindate:+ status:+ type: string+ example: online+ flags:+ type: number+ example: 0+ followercount:+ type: number+ example: 2+ followingcount:type: number- example: 1585337827953\ No newline at end of file+ example: 5+ cover:url:+ type: string+ example: /assets/profile/1-cover.png+ cover:position:+ type: string+ example: 50.0301% 19.2464%+ groupTitle:+ type: string+ example: "[\"administrators\",\"Staff\"]"+ groupTitleArray:+ type: array+ example:+ - administrators+ - Staff+ icon:text:+ type: string+ example: D+ icon:bgColor:+ type: string+ example: "#9c27b0"+ joindateISO:+ type: string+ example: 2020-03-27T20:30:36.590Z+ lastonlineISO:+ type: string+ example: 2020-03-27T20:30:36.590Z+ banned_until:+ type: number+ example: 0+ banned_until_readable:+ type: string+ example: Not Banned\ No newline at end of filediff --git a/src/middleware/index.js b/src/middleware/index.jsindex b7e4e0d701..60f9ebf4fa 100644--- a/src/middleware/index.js+++ b/src/middleware/index.js@@ -243,7 +243,7 @@ middleware.checkRequired = function (fields, req, res, next) {const missing = fields.filter(field => !req.body.hasOwnProperty(field));if (!missing.length) {- next();+ return next();}controllers.helpers.formatApiResponse(400, res, new Error('Required parameters were missing from this API call: ' + missing.join(', ')));diff --git a/src/routes/write/users.js b/src/routes/write/users.jsindex cf08b6f5d3..6df2c08300 100644--- a/src/routes/write/users.js+++ b/src/routes/write/users.js@@ -17,9 +17,7 @@ module.exports = function () {app.post('/', middleware.checkRequired.bind(null, ['username']), middleware.authenticate, middleware.isAdmin, async (req, res) => {const uid = await users.create(req.body);- helpers.formatApiResponse(200, res, {- uid: uid,- });+ helpers.formatApiResponse(200, res, await users.getUserData(uid));});// app.route('/:uid')