Preventing shuffling of playlists you don't own

This commit is contained in:
James Barnsley
2017-01-27 12:13:18 +13:00
parent 60f49d4611
commit c22c93428d
2 changed files with 6 additions and 0 deletions

View File

@ -161,6 +161,7 @@ export let getFromUri = function( element, uri ){
if( element == 'userid' && exploded[1] == 'user' ) return exploded[2];
if( element == 'playlistid' && exploded[3] == 'playlist' ) return exploded[4];
if( element == 'artistid' && exploded[1] == 'artist' ) return exploded[2];
if( element == 'artistid' && exploded[3] == 'playlist' ) return exploded[2];
if( element == 'albumid' && exploded[1] == 'album' ) return exploded[2];
if( element == 'trackid' && exploded[1] == 'track' ) return exploded[2];
return null;

View File

@ -56,6 +56,11 @@ const SpotifyMiddleware = (function(){
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
return
}
if( !store.getState().spotify.me || store.getState().spotify.me.id != helpers.getFromUri('artistid',action.key) ){
store.dispatch( uiActions.createNotification( "You can't edit a playlist you don't own", 'bad' ) )
return
}
store.dispatch( spotifyActions.reorderPlaylistTracks( action.key, action.range_start, action.range_length, action.insert_before, action.snapshot_id ))
break