diff --git a/seasoned_api/src/tmdb/convertTmdbToMovie.js b/seasoned_api/src/tmdb/convertTmdbToMovie.js index d9e4d5e..9d06ca0 100644 --- a/seasoned_api/src/tmdb/convertTmdbToMovie.js +++ b/seasoned_api/src/tmdb/convertTmdbToMovie.js @@ -11,35 +11,35 @@ function convertTmdbToMovie(tmdbMovie, credits=undefined) { movie.credits = credits; } - if (tmdbMovie.release_date !== undefined) { + if (tmdbMovie.release_date !== undefined && tmdbMovie.genres) { movie.release_date = new Date(tmdbMovie.release_date); movie.year = movie.release_date.getFullYear(); } - if (tmdbMovie.poster_path !== undefined) { + if (tmdbMovie.poster_path !== undefined && tmdbMovie.genres) { movie.poster = tmdbMovie.poster_path; } - if (tmdbMovie.backdrop_path !== undefined) { + if (tmdbMovie.backdrop_path !== undefined && tmdbMovie.genres) { movie.backdrop = tmdbMovie.backdrop_path; } - if (tmdbMovie.status !== undefined) { + if (tmdbMovie.status !== undefined && tmdbMovie.genres) { movie.status = tmdbMovie.status; } - if (tmdbMovie.genres !== undefined) { + if (tmdbMovie.genres !== undefined && tmdbMovie.genres) { movie.genres = tmdbMovie.genres.map(genre => genre.name); } - if (tmdbMovie.tagline !== undefined) { + if (tmdbMovie.tagline !== undefined && tmdbMovie.genres) { movie.tagline = tmdbMovie.tagline; } - if (tmdbMovie.runtime !== undefined) { + if (tmdbMovie.runtime !== undefined && tmdbMovie.genres) { movie.runtime = tmdbMovie.runtime; } - if (tmdbMovie.imdb_id !== undefined) { + if (tmdbMovie.imdb_id !== undefined && tmdbMovie.genres) { movie.imdb_id = tmdbMovie.imdb_id; } diff --git a/seasoned_api/src/tmdb/convertTmdbToSeasoned.js b/seasoned_api/src/tmdb/convertTmdbToSeasoned.js index b89fd44..cd552c2 100644 --- a/seasoned_api/src/tmdb/convertTmdbToSeasoned.js +++ b/seasoned_api/src/tmdb/convertTmdbToSeasoned.js @@ -15,25 +15,7 @@ function convertType(tmdbType) { } function convertTmdbToMovie(tmdb) { - const year = - const movie = new Movie(); - let seasoned = undefined; - - if (tmdb.id && tmdb.title && tmdb.release_date) { - const year = tmdb.release_date.getFullYear(); - seasoned = new Movie(tmdb.id, tmdb.title, year); - } - else if (tmdb.id && tmdb.name && tmdb.first_air_date) { - const year = tmdb.first_air_date.getFullYear(); - seasoned = new Show(tmdb.id, tmdb.name, year); - seasoned.seasons = tmdb.number_of_season; - seasoned.episodes = tmdb.episodes; - return - } -} - - - const title = tmdb.title || tmdb.name; + const title = tmdb.title || tmdb.name; const year = translateYear(tmdb.release_date || tmdb.first_air_date); const type = manualType || convertType(tmdb.type) || 'movie'; diff --git a/seasoned_api/src/user/token.js b/seasoned_api/src/user/token.js index 0590dc3..f8e0112 100644 --- a/seasoned_api/src/user/token.js +++ b/seasoned_api/src/user/token.js @@ -33,7 +33,7 @@ class Token { let username = null; const token = jwt.verify(jwtToken, secret, { clockTolerance: 10000 }) - if (token.username === undefined) + if (token.username === undefined || token.username === null) throw new Error('Malformed token') username = token.username diff --git a/seasoned_api/src/user/userSecurity.js b/seasoned_api/src/user/userSecurity.js index 571ec58..d878664 100644 --- a/seasoned_api/src/user/userSecurity.js +++ b/seasoned_api/src/user/userSecurity.js @@ -21,7 +21,7 @@ class UserSecurity { return Promise.resolve() .then(() => this.userRepository.create(user)) .then(() => UserSecurity.hashPassword(clearPassword)) - .then(hash => this.userRepository.changePassword(user, hash)); + .then(hash => this.userRepository.changePassword(user, hash)) } } @@ -61,7 +61,7 @@ class UserSecurity { */ static hashPassword(clearPassword) { return new Promise((resolve) => { - const salatRounds = 10; + const saltRounds = 10; bcrypt.hash(clearPassword, saltRounds, (error, hash) => { resolve(hash); });