tomRedox/simpleCRM

No feedback to user when wrong password is entered

lc3t35 opened this issue · 1 comments

When an incorrect password is entered, there is no message/alert displayed to the user.
We can just see in console

Object { stack: "Meteor.makeErrorType/errorClass@htt…", error: 403, reason: "Incorrect password", details: undefined, message: "Incorrect password [403]", errorType: "Meteor.Error" }

Add package chrismbeckett:toastr, and in import/ui/security/login.jsx

Meteor.loginWithPassword( emailAddress, password, ( error ) => {
        if ( error ) {
          console.log(error);
          toastr.error(error.message);
        } else {
          FlowRouter.go( 'Home' );
        }
      });

If you want a better rendering, create this errors.js

throwError = function(message) {
    toastr.options = {
      "closeButton": true,
      "debug": false,
      "newestOnTop": false,
      "progressBar": false,
      "positionClass": "toast-top-full-width",
      "preventDuplicates": false,
      "onclick": null,
      "showDuration": "300",
      "hideDuration": "1000",
      "timeOut": "10000",
      "extendedTimeOut": "1000",
      "showEasing": "swing",
      "hideEasing": "linear",
      "showMethod": "fadeIn",
      "hideMethod": "fadeOut"
    };
    toastr.error(message);
}

throwWarning = function(message) {
    toastr.options = {
      "closeButton": true,
      "debug": false,
      "newestOnTop": false,
      "progressBar": false,
      "positionClass": "toast-top-full-width",
      "preventDuplicates": false,
      "onclick": null,
      "showDuration": "300",
      "hideDuration": "1000",
      "timeOut": "10000",
      "extendedTimeOut": "1000",
      "showEasing": "swing",
      "hideEasing": "linear",
      "showMethod": "fadeIn",
      "hideMethod": "fadeOut"
    };
    toastr.warning(message);
}

and call throwError(error.message)