auth register - maximesenecal/planitpoker-api GitHub Wiki
Requête et réponse lors de l'enregistrement d'un utilisateur
POST /auth/signup HTTP/1.1
Host: localhost:1337
Cache-Control: no-cache
{
"username":"testsdude",
"email":"[email protected]",
"password":"tsestdude"
}
"code": "CREATED",
"message": "The request has resulted in a new resource being created",
"data": {
"token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXJuYW1lIjoidGVzdHNkdWRlIiwiZW1haWwiOiJ0ZXNzdDFAdGVzdC5jb20iLCJjcmVhdGVkQXQiOiIyMDE3LTAxLTIzVDE0OjUyOjAzLjkzM1oiLCJ1cGRhdGVkQXQiOiIyMDE3LTAxLTIzVDE0OjUyOjAzLjkzM1oiLCJpZCI6IjU4ODYxODkzOGFhMDM2YTAxNDgxMDk2YiJ9LCJpYXQiOjE0ODUxODMxMjMsImV4cCI6MTQ4NTI2OTUyMywiYXVkIjoicGxhbml0cG9rZXIuY29tIiwiaXNzIjoicGxhbml0cG9rZXIuY29tIn0.OEdhoaPIs4PmGpZ-sREmB8xiD0qN7W5a-yxFNIqUxKoHErwJg9svKYTA9vHT1za3fZu5Kp6CLdl9mHw3Wg9AKg",
"user": {
"username": "testsdude",
"email": "[email protected]",
"createdAt": "2017-01-23T14:52:03.933Z",
"updatedAt": "2017-01-23T14:52:03.933Z",
"id": "588618938aa036a01481096b"
}
}
{
"code": "E_VALIDATION",
"invalidAttributes": {
"email": [
{
"rule": "unique",
"value": "[email protected]",
"message": "A record with that `email` already exists (`[email protected]`)."
}
]
},
"originalError": {
"code": 11000,
"index": 0,
"errmsg": "E11000 duplicate key error collection: PlanItPoker.user index: email_1 dup key: { : \"[email protected]\" }",
"op": {
"username": "testsdude",
"email": "[email protected]",
"password": "$2a$10$44.BzuCXGa62qh/4hCJOHeLzODyZdwlwofLwPN5QqG2pVMkNWNbY2",
"createdAt": "2017-01-24T11:03:50.896Z",
"updatedAt": "2017-01-24T11:03:50.896Z",
"_id": "58873496b709d2b81a78daf6"
}
},
"_e": {
"code": 11000,
"index": 0,
"errmsg": "E11000 duplicate key error collection: PlanItPoker.user index: email_1 dup key: { : \"[email protected]\" }",
"op": {
"username": "testsdude",
"email": "[email protected]",
"password": "$2a$10$44.BzuCXGa62qh/4hCJOHeLzODyZdwlwofLwPN5QqG2pVMkNWNbY2",
"createdAt": "2017-01-24T11:03:50.896Z",
"updatedAt": "2017-01-24T11:03:50.896Z",
"_id": "58873496b709d2b81a78daf6"
}
},
"rawStack": "MongoError: E11000 duplicate key error collection: PlanItPoker.user index: email_1 dup key: { : \"[email protected]\" }\n at Function.MongoError.create (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\error.js:31:11)\n at toError (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb\\lib\\utils.js:114:22)\n at D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb\\lib\\collection.js:620:23\n at handleCallback (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb\\lib\\utils.js:96:12)\n at resultHandler (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb\\lib\\bulk\\ordered.js:426:14)\n at commandCallback (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\topologies\\server.js:1213:9)\n at Callbacks.emit (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\topologies\\server.js:119:3)\n at Connection.messageHandler (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\topologies\\server.js:371:23)\n at Socket.<anonymous> (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\connection\\connection.js:301:22)\n at emitOne (events.js:96:13)\n at Socket.emit (events.js:188:7)\n at readableAddChunk (_stream_readable.js:176:18)\n at Socket.Readable.push (_stream_readable.js:134:10)\n at TCP.onread (net.js:548:20)",
"details": "Invalid attributes sent to undefined:\n • email\n • A record with that `email` already exists (`[email protected]`).\n",
"reason": "1 attribute is invalid",
"status": 400,
"isOperational": true,
"message": "[Error (E_VALIDATION) 1 attribute is invalid] Invalid attributes sent to undefined:\n • email\n • A record with that `email` already exists (`[email protected]`).\n",
"stack": "Error (E_VALIDATION) :: 1 attribute is invalid\nMongoError: E11000 duplicate key error collection: PlanItPoker.user index: email_1 dup key: { : \"[email protected]\" }\n at Function.MongoError.create (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\error.js:31:11)\n at toError (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb\\lib\\utils.js:114:22)\n at D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb\\lib\\collection.js:620:23\n at handleCallback (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb\\lib\\utils.js:96:12)\n at resultHandler (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb\\lib\\bulk\\ordered.js:426:14)\n at commandCallback (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\topologies\\server.js:1213:9)\n at Callbacks.emit (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\topologies\\server.js:119:3)\n at Connection.messageHandler (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\topologies\\server.js:371:23)\n at Socket.<anonymous> (D:\\Projets\\nodejs\\PlanItPoker-api\\node_modules\\mongodb-core\\lib\\connection\\connection.js:301:22)\n at emitOne (events.js:96:13)\n at Socket.emit (events.js:188:7)\n at readableAddChunk (_stream_readable.js:176:18)\n at Socket.Readable.push (_stream_readable.js:134:10)\n at TCP.onread (net.js:548:20)"
}