mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-11-24 03:35:17 +03:00
[docs] Updates todo app docs (#677)
* Changed HttpError from 403 to 401
This commit is contained in:
parent
8bae408298
commit
0de9997198
@ -220,7 +220,7 @@ Next, let's update the queries and actions to forbid access to non-authenticated
|
|||||||
import HttpError from '@wasp/core/HttpError.js'
|
import HttpError from '@wasp/core/HttpError.js'
|
||||||
|
|
||||||
export const getTasks = async (args, context) => {
|
export const getTasks = async (args, context) => {
|
||||||
if (!context.user) { throw new HttpError(403) }
|
if (!context.user) { throw new HttpError(401) }
|
||||||
return context.entities.Task.findMany(
|
return context.entities.Task.findMany(
|
||||||
{ where: { user: { id: context.user.id } } }
|
{ where: { user: { id: context.user.id } } }
|
||||||
)
|
)
|
||||||
@ -231,7 +231,7 @@ export const getTasks = async (args, context) => {
|
|||||||
import HttpError from '@wasp/core/HttpError.js'
|
import HttpError from '@wasp/core/HttpError.js'
|
||||||
|
|
||||||
export const createTask = async ({ description }, context) => {
|
export const createTask = async ({ description }, context) => {
|
||||||
if (!context.user) { throw new HttpError(403) }
|
if (!context.user) { throw new HttpError(401) }
|
||||||
return context.entities.Task.create({
|
return context.entities.Task.create({
|
||||||
data: {
|
data: {
|
||||||
description,
|
description,
|
||||||
@ -241,7 +241,7 @@ export const createTask = async ({ description }, context) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const updateTask = async ({ taskId, data }, context) => {
|
export const updateTask = async ({ taskId, data }, context) => {
|
||||||
if (!context.user) { throw new HttpError(403) }
|
if (!context.user) { throw new HttpError(401) }
|
||||||
return context.entities.Task.updateMany({
|
return context.entities.Task.updateMany({
|
||||||
where: { id: taskId, user: { id: context.user.id } },
|
where: { id: taskId, user: { id: context.user.id } },
|
||||||
data: { isDone: data.isDone }
|
data: { isDone: data.isDone }
|
||||||
|
Loading…
Reference in New Issue
Block a user