server/services/authService.js
// Finds a user by the specified token and returns the user
Finds a user by the specified token and returns the user
Finds a user by the specified token and returns the user
static findUserByToken(token, isActive = true) {
    return new Promise((resolve, reject) => {
      try {
        const decoded = jwt.decode(token, JwtSecret);
        if (decoded.expireDate > Date.now()) {
          return User.findOne({ username: decoded.username, active: isActive }).exec().then((user) => {
            if (user) {
              return resolve(user);
            }
            return reject();
          });
        }
        return reject();
      }
      catch (err) {
        return reject();
      }
    });
  }
static findUserByToken ( token , isActive = true ) { return new Promise ( ( resolve , reject ) => { try { const decoded = jwt . decode ( token , JwtSecret ) ; if ( decoded . expireDate > Date . now ( ) ) { return User . findOne ( { username : decoded . username , active : isActive } ) . exec ( ) . then ( ( user ) => { if ( user ) { return resolve ( user ) ; } return reject ( ) ; } ) ; } return reject ( ) ; } catch ( err ) { return reject ( ) ; } } ) ; }
Finds a user by the specified token and returns the user
Finds a user by the specified token and returns the user