Spotify.access will be checker for full access

This commit is contained in:
James Barnsley
2017-08-04 22:33:49 +12:00
parent c2b8cfb346
commit e1ee57bdad
15 changed files with 100 additions and 92 deletions

View File

@ -112,7 +112,7 @@ function getToken( dispatch, getState ){
function refreshToken( dispatch, getState ){
return new Promise( (resolve, reject) => {
if (getState().spotify.authorized){
if (getState().spotify.authorization && getState().spotify.authentication_provider == 'http_api'){
$.ajax({
method: 'GET',
@ -204,7 +204,7 @@ export function authorizationGranted( data ){
return { type: 'SPOTIFY_AUTHORIZATION_GRANTED', data: data }
}
export function authorizationRevoked(){
export function revokeAuthorization(){
return { type: 'SPOTIFY_AUTHORIZATION_REVOKED' }
}

View File

@ -68,7 +68,7 @@ const SpotifyMiddleware = (function(){
break
case 'SPOTIFY_CREATE_PLAYLIST':
if( !store.getState().spotify.authorized ){
if( !store.getState().spotify.authorization ){
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
return
}
@ -78,7 +78,7 @@ const SpotifyMiddleware = (function(){
case 'SPOTIFY_REMOVE_PLAYLIST_TRACKS':
var playlist = state.core.playlists[action.key]
if( !store.getState().spotify.authorized ){
if( !store.getState().spotify.authorization ){
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
return
}
@ -92,7 +92,7 @@ const SpotifyMiddleware = (function(){
case 'SPOTIFY_ADD_PLAYLIST_TRACKS':
if( !store.getState().spotify.authorized ){
if( !store.getState().spotify.authorization ){
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
return
}
@ -102,7 +102,7 @@ const SpotifyMiddleware = (function(){
case 'SPOTIFY_REORDER_PLAYLIST_TRACKS':
if( !store.getState().spotify.authorized ){
if( !store.getState().spotify.authorization ){
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
return
}
@ -117,7 +117,7 @@ const SpotifyMiddleware = (function(){
case 'SPOTIFY_SAVE_PLAYLIST':
if( !store.getState().spotify.authorized ){
if( !store.getState().spotify.authorization ){
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
return
}

View File

@ -18,7 +18,7 @@ export default function reducer(spotify = {}, action){
var spotify = Object.assign({},spotify,action.config)
let access = 'none'
if (spotify.authentication_provider == 'http_api' && spotify.authorized){
if (spotify.authentication_provider == 'http_api' && spotify.authorization){
access = 'full'
} else if (spotify.authentication_provider == 'backend' && spotify.backend_username){
access = 'limited'
@ -27,7 +27,7 @@ export default function reducer(spotify = {}, action){
return spotify
case 'PUSHER_SPOTIFY_TOKEN':
if( spotify.authorized ) return spotify;
if( spotify.authorization ) return spotify;
return Object.assign({}, spotify, {
authorizing: false,
authorization: false,