message: Set error on error
diff: import {User} from '../models/User';
  import {Strategy as LocalStrategy} from 'passport-local';
  import {isNullOrUndefined} from 'util';
  +import {UnauthorizedError} from 'routing-controllers';
  export default new LocalStrategy(
  {
  usernameField: 'email'
  },
  - (email, password, done) => {
  - User.findOne({email: email})
  - .then((user) => {
  + async (email, password, done: (err: any, user: any) => any) => {
  + try {
  + const user = await User.findOne({email: email});
  if (!user) {
  - return done(null, false, {message: 'Your login details could not be verified. Please try again.'});
  + return done(new UnauthorizedError('couldNotBeVerified'), null);
  }
  // dismiss password reset process
  if (!isNullOrUndefined(user.resetPasswordToken)) {
  user.resetPasswordToken = undefined;
  user.resetPasswordExpires = undefined;
  - user.save();
  + await user.save();
  }
  - user.isValidPassword(password)
  - .then((isValid) => {
  + const isValid = await user.isValidPassword(password);
  if (!isValid) {
  - return done(null, false, {message: 'Your login details could not be verified. Please try again.'});
  + return done(new UnauthorizedError('couldNotBeVerified'), null);
  } else if (!user.isActive) {
  - return done(null, false, {message: 'Your account has not been activated yet.'});
  + return done(new UnauthorizedError('notActiveYet'), null);
  } else {
  return done(null, user);
  }
  - });
  - })
  - .catch(done);
  + } catch (err) {
  + done(new UnauthorizedError('unknown'), null);
  + }
  });
  