correct put call to not remove password 😅
This commit is contained in:
parent
7c2b5e1858
commit
eec2c4de7c
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<div class="inputs">
|
<div class="inputs">
|
||||||
<Input
|
<Input
|
||||||
disabled={!editMode}
|
disabled
|
||||||
thin
|
thin
|
||||||
bind:value={user.username}
|
bind:value={user.username}
|
||||||
name="Name"
|
name="Name"
|
||||||
|
|
|
@ -7,7 +7,7 @@ const {
|
||||||
ADMIN_LEVEL_ID,
|
ADMIN_LEVEL_ID,
|
||||||
} = require("../../utilities/accessLevels")
|
} = require("../../utilities/accessLevels")
|
||||||
|
|
||||||
exports.fetch = async function(ctx) {
|
exports.fetch = async function (ctx) {
|
||||||
const database = new CouchDB(ctx.user.instanceId)
|
const database = new CouchDB(ctx.user.instanceId)
|
||||||
const data = await database.query("database/by_type", {
|
const data = await database.query("database/by_type", {
|
||||||
include_docs: true,
|
include_docs: true,
|
||||||
|
@ -17,7 +17,7 @@ exports.fetch = async function(ctx) {
|
||||||
ctx.body = data.rows.map(row => row.doc)
|
ctx.body = data.rows.map(row => row.doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.create = async function(ctx) {
|
exports.create = async function (ctx) {
|
||||||
const database = new CouchDB(ctx.user.instanceId)
|
const database = new CouchDB(ctx.user.instanceId)
|
||||||
const appId = (await database.get("_design/database")).metadata.applicationId
|
const appId = (await database.get("_design/database")).metadata.applicationId
|
||||||
const { username, password, name, accessLevelId } = ctx.request.body
|
const { username, password, name, accessLevelId } = ctx.request.body
|
||||||
|
@ -63,11 +63,13 @@ exports.create = async function(ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.update = async function(ctx) {
|
exports.update = async function (ctx) {
|
||||||
const db = new CouchDB(ctx.user.instanceId)
|
const db = new CouchDB(ctx.user.instanceId)
|
||||||
const user = ctx.request.body
|
const user = ctx.request.body
|
||||||
|
const dbUser = db.get(ctx.request.body._id)
|
||||||
|
const newData = { ...dbUser, ...user }
|
||||||
|
|
||||||
const response = await db.put(user)
|
const response = await db.put(newData)
|
||||||
user._rev = response.rev
|
user._rev = response.rev
|
||||||
|
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
|
@ -75,14 +77,14 @@ exports.update = async function(ctx) {
|
||||||
ctx.body = response
|
ctx.body = response
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.destroy = async function(ctx) {
|
exports.destroy = async function (ctx) {
|
||||||
const database = new CouchDB(ctx.user.instanceId)
|
const database = new CouchDB(ctx.user.instanceId)
|
||||||
await database.destroy(getUserId(ctx.params.username))
|
await database.destroy(getUserId(ctx.params.username))
|
||||||
ctx.message = `User ${ctx.params.username} deleted.`
|
ctx.message = `User ${ctx.params.username} deleted.`
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.find = async function(ctx) {
|
exports.find = async function (ctx) {
|
||||||
const database = new CouchDB(ctx.user.instanceId)
|
const database = new CouchDB(ctx.user.instanceId)
|
||||||
const user = await database.get(getUserId(ctx.params.username))
|
const user = await database.get(getUserId(ctx.params.username))
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
|
|
Loading…
Reference in New Issue