Throw more errors and cleanup some unmerged code

This commit is contained in:
2019-07-26 21:55:59 +02:00
parent 23f9911237
commit 04ba094a14
4 changed files with 12 additions and 30 deletions

View File

@@ -11,35 +11,35 @@ function convertTmdbToMovie(tmdbMovie, credits=undefined) {
movie.credits = credits; movie.credits = credits;
} }
if (tmdbMovie.release_date !== undefined) { if (tmdbMovie.release_date !== undefined && tmdbMovie.genres) {
movie.release_date = new Date(tmdbMovie.release_date); movie.release_date = new Date(tmdbMovie.release_date);
movie.year = movie.release_date.getFullYear(); movie.year = movie.release_date.getFullYear();
} }
if (tmdbMovie.poster_path !== undefined) { if (tmdbMovie.poster_path !== undefined && tmdbMovie.genres) {
movie.poster = tmdbMovie.poster_path; movie.poster = tmdbMovie.poster_path;
} }
if (tmdbMovie.backdrop_path !== undefined) { if (tmdbMovie.backdrop_path !== undefined && tmdbMovie.genres) {
movie.backdrop = tmdbMovie.backdrop_path; movie.backdrop = tmdbMovie.backdrop_path;
} }
if (tmdbMovie.status !== undefined) { if (tmdbMovie.status !== undefined && tmdbMovie.genres) {
movie.status = tmdbMovie.status; movie.status = tmdbMovie.status;
} }
if (tmdbMovie.genres !== undefined) { if (tmdbMovie.genres !== undefined && tmdbMovie.genres) {
movie.genres = tmdbMovie.genres.map(genre => genre.name); movie.genres = tmdbMovie.genres.map(genre => genre.name);
} }
if (tmdbMovie.tagline !== undefined) { if (tmdbMovie.tagline !== undefined && tmdbMovie.genres) {
movie.tagline = tmdbMovie.tagline; movie.tagline = tmdbMovie.tagline;
} }
if (tmdbMovie.runtime !== undefined) { if (tmdbMovie.runtime !== undefined && tmdbMovie.genres) {
movie.runtime = tmdbMovie.runtime; movie.runtime = tmdbMovie.runtime;
} }
if (tmdbMovie.imdb_id !== undefined) { if (tmdbMovie.imdb_id !== undefined && tmdbMovie.genres) {
movie.imdb_id = tmdbMovie.imdb_id; movie.imdb_id = tmdbMovie.imdb_id;
} }

View File

@@ -15,25 +15,7 @@ function convertType(tmdbType) {
} }
function convertTmdbToMovie(tmdb) { function convertTmdbToMovie(tmdb) {
const year = const title = tmdb.title || tmdb.name;
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 year = translateYear(tmdb.release_date || tmdb.first_air_date); const year = translateYear(tmdb.release_date || tmdb.first_air_date);
const type = manualType || convertType(tmdb.type) || 'movie'; const type = manualType || convertType(tmdb.type) || 'movie';

View File

@@ -33,7 +33,7 @@ class Token {
let username = null; let username = null;
const token = jwt.verify(jwtToken, secret, { clockTolerance: 10000 }) const token = jwt.verify(jwtToken, secret, { clockTolerance: 10000 })
if (token.username === undefined) if (token.username === undefined || token.username === null)
throw new Error('Malformed token') throw new Error('Malformed token')
username = token.username username = token.username

View File

@@ -21,7 +21,7 @@ class UserSecurity {
return Promise.resolve() return Promise.resolve()
.then(() => this.userRepository.create(user)) .then(() => this.userRepository.create(user))
.then(() => UserSecurity.hashPassword(clearPassword)) .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) { static hashPassword(clearPassword) {
return new Promise((resolve) => { return new Promise((resolve) => {
const salatRounds = 10; const saltRounds = 10;
bcrypt.hash(clearPassword, saltRounds, (error, hash) => { bcrypt.hash(clearPassword, saltRounds, (error, hash) => {
resolve(hash); resolve(hash);
}); });