angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.12k stars 1.23k forks source link

Backend Validation for Unique Email for Sql Buggy #2159

Open atodicebear opened 8 years ago

atodicebear commented 8 years ago
Item Version
generator-angular-fullstack 3.7.5
Node 4.4.5
npm 3.9.6
Operating System Windows7
yo 1.8.4
Item Answer
Transpiler Babel
Markup HTML
CSS SCSS
Router ui-router
Build Tool Gulp
Client Tests Mocha
DB MsSQL
Auth Y
etc etc

Hey, I have Installed this Generator anew using: yo angular-fullstack For the Validation with MsSql for unique Email there is a Bug?

 // Update validity of form fields that match the sequelize errors
          if (err.name) {
            angular.forEach(err.fields, field => {
              form[field].$setValidity('mongoose', false);
              this.errors[field] = err.message;
            });
          }
        });

This is the Generated code for SQL user. It throws normally a 422 Error but as well TypeError: Cannot read property '$setValidity' of undefined So as well there is no "This Email is alrleady used..." Error Message output. Changing the code to the same as for MongoDb

 // Update validity of form fields that match the sequelize errors
          if (err.name) {
            angular.forEach(err.fields, (error,field) => {
              form[field].$setValidity('mongoose', false);
              this.errors[field] = err.message;
            });
          }
        });

Solves the Problem. Tried it with the Generated Admin and TestUser after a Clean Install.

Awk34 commented 8 years ago

Feel free to submit a PR

Demonium commented 7 years ago

Hi, I have an issue regarding this topic. I put an existing email address in the form click on "sign up" and getting error 422 => normal in the nodejs console I'm getting the error below: Executing (default): INSERT INTO Users (_id,name,email,internal_email,role,password,provider,salt) VALUES (DEFAULT,'test','test@gmail.com','test@test.fr','user','CeiqN+pCZCY8/86+MQoUIvSKojbLZlQniIfI4kayJrMvMa/o1LppD3KAtDuE+tuqT0wUI9hAUfG4oJelps75rQ==','local','WxLbAbRP/ULOS7K2cYvUeA=='); POST /api/users 422 553.678 ms - - Changing the address mail "test@gmail.com" with "test1@gmail.com" click again on "sign up" and nothing append. On client side the function register is callend but I get nothing on the server side. I'm working on node 6.2.2 OS debian and database is MySql