Browse Source

Fixed some issues with auth and station headers.

KrisVos130 8 years ago
parent
commit
cb8fe3b83c

+ 1 - 1
backend/logic/actions/stations.js

@@ -249,7 +249,7 @@ module.exports = {
 				if (err) return cb({ status: 'failure', message: 'Something went wrong when saving the station.' });
 				stations.updateStation(stationId, (err, station) => {
 					cache.pub('station.voteSkipSong', stationId);
-					if (station.currentSong && station.currentSong.skipVotes.length >= 1) {
+					if (station.currentSong && station.currentSong.skipVotes.length >= 3) {
 						stations.skipStation(stationId)();
 					}
 					cb({ status: 'success', message: 'Successfully voted to skip the song.' });

+ 1 - 0
backend/logic/io.js

@@ -90,6 +90,7 @@ module.exports = {
 					if (err && err !== true) socket.emit('ready', false);
 					else if (session && session.userId) {
 						db.models.user.findOne({ _id: session.userId }, (err, user) => {
+							if (err || !user) return socket.emit('ready', false);
 							let role = '';
 							let username = '';
 							let userId = '';

+ 3 - 3
frontend/components/Station/CommunityHeader.vue

@@ -19,7 +19,7 @@
 					<i class='material-icons'>skip_next</i>
 				</span>
 			</a>
-			<a v-if='!isOwner() && $parent.$parent.loggedIn && $parent.currentSong' class='nav-item' href='#' @click='$parent.voteSkipStation()'>
+			<a v-if='!isOwner() && $parent.$parent.loggedIn && !$parent.noSong' class='nav-item' href='#' @click='$parent.voteSkipStation()'>
 				<span class='icon'>
 					<i class='material-icons'>skip_next</i>
 				</span>
@@ -63,7 +63,7 @@
 					<i class='material-icons'>people</i>
 				</span>
 			</a>-->
-			<a class='nav-item' href='#' @click='$parent.sidebars.playlist = !$parent.sidebars.playlist'>
+			<a class='nav-item' href='#' @click='$parent.sidebars.playlist = !$parent.sidebars.playlist' v-if='$parent.$parent.loggedIn'>
 				<span class='icon'>
 					<i class='material-icons'>library_music</i>
 				</span>
@@ -82,7 +82,7 @@
 		},
 		methods: {
 			isOwner: function () {
-				return this.$parent.$parent.role === 'admin' || this.$parent.$parent.userId === this.$parent.station.owner
+				return this.$parent.$parent.loggedIn && (this.$parent.$parent.role === 'admin' || this.$parent.$parent.userId === this.$parent.station.owner);
 			}
 		}
 	}

+ 8 - 3
frontend/components/Station/OfficialHeader.vue

@@ -9,7 +9,7 @@
 					<i class='material-icons'>settings</i>
 				</span>
 			</a>
-			<a class='nav-item' href='#' @click='$parent.toggleModal("addSongToQueue")' v-if='$parent.type === "official"'>
+			<a class='nav-item' href='#' @click='$parent.toggleModal("addSongToQueue")' v-if='$parent.type === "official" && $parent.$parent.loggedIn'>
 				<span class='icon'>
 					<i class='material-icons'>queue_music</i>
 				</span>
@@ -24,7 +24,7 @@
 					<i class='material-icons'>skip_next</i>
 				</span>
 			</a>
-			<a v-if='!isOwner() && $parent.$parent.loggedIn && $parent.currentSong' class='nav-item' href='#' @click='$parent.voteSkipStation()'>
+			<a v-if='!isOwner() && $parent.$parent.loggedIn && !$parent.noSong' class='nav-item' href='#' @click='$parent.voteSkipStation()'>
 				<span class='icon'>
 					<i class='material-icons'>skip_next</i>
 				</span>
@@ -87,7 +87,7 @@
 		},
 		methods: {
 			isOwner: function () {
-				return this.$parent.$parent.role === 'admin' || this.$parent.$parent.userId === this.$parent.station.owner
+				return this.$parent.$parent.loggedIn && this.$parent.$parent.role === 'admin';
 			}
 		}
 	}
@@ -118,6 +118,11 @@
 		}
 	}
 
+	.skip-votes {
+		position: relative;
+		left: 11px;
+	}
+
 	.nav-toggle {
 		height: 64px;
 	}