438174 (3) [Avatar] Offline
#1
Hi everybody,

I have an error 500 when i tried to signup with an adress mail that already exist.
But i have not the error 409 expected.

In the userController, the "err.invalidAttributes" is undifined and not correspond to the test of the usercontroler.

Can you help me please?
438174 (3) [Avatar] Offline
#2
the error msg in the userController with a console.log(err)
[Error (E_UNKNOWN) Encountered an unexpected error] Details: error: la valeur d'une clé dupliquée rompt la contrainte unique « user_email_key »

the error msg in the front end:
An unexpected error occurred: {"originalError":{"name":"error","length":231,"severity":"ERREUR","code":"23505","detail":"La clé « (email)=(sailsinaction@gmail.com) » existe déjà.","schema":"public","table":"user","constraint":"user_email_key","file":"nbtinsert.c","line":"406","routine":"_bt_check_unique"},"_e":{"name":"error","length":231,"severity":"ERREUR","code":"23505","detail":"La clé « (email)=(sailsinaction@gmail.com) » existe déjà.","schema":"public","table":"user","constraint":"user_email_key","file":"nbtinsert.c","line":"406","routine":"_bt_check_unique"},"rawStack":"error: la valeur d'une clé dupliquée rompt la contrainte unique « user_email_key »\n at Connection.parseE (/var/www/brushfire/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:539:11)\n at Connection.parseMessage (/var/www/brushfire/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:366:17)\n at Socket.<anonymous> (/var/www/brushfire/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)\n at emitOne (events.js:77:13)\n at Socket.emit (events.js:169:7)\n at readableAddChunk (_stream_readable.js:153:18)\n at Socket.Readable.push (_stream_readable.js:111:10)\n at TCP.onread (net.js:531:20)","details":"Details: error: la valeur d'une clé dupliquée rompt la contrainte unique « user_email_key »\n","message":"[Error (E_UNKNOWN) Encountered an unexpected error] Details: error: la valeur d'une clé dupliquée rompt la contrainte unique « user_email_key »\n","stack":"Error (E_UNKNOWN) :: Encountered an unexpected error\nerror: la valeur d'une clé dupliquée rompt la contrainte unique « user_email_key »\n at Connection.parseE (/var/www/brushfire/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:539:11)\n at Connection.parseMessage (/var/www/brushfire/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:366:17)\n at Socket.<anonymous> (/var/www/brushfire/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)\n at emitOne (events.js:77:13)\n at Socket.emit (events.js:169:7)\n at readableAddChunk (_stream_readable.js:153:18)\n at Socket.Readable.push (_stream_readable.js:111:10)\n at TCP.onread (net.js:531:20)"}
438174 (3) [Avatar] Offline
#3
if (err.originalError == 'error: la valeur d\'une clé dupliquée rompt la contrainte unique « user_email_key »'){
                    return res.send(409, 'Email address is already taken by another user, please try again.');
                  }
                  if (err.originalError == 'error: la valeur d\'une clé dupliquée rompt la contrainte unique « user_username_key »'){
                    return res.send(409, 'Username is already taken by another user, please try again.');
                  }

I do this until i found another solution