From e1e39000abdd325379be7448ab963bb654ebafbd Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Mon, 13 Apr 2020 14:15:22 +1200 Subject: [PATCH] Notifying user to revoke shared tokens --- src/js/services/lastfm/middleware.js | 23 +++++++++++++++++++++++ src/js/services/spotify/middleware.js | 18 ++++++++++++++++-- src/scss/components/_notifications.scss | 1 + 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/js/services/lastfm/middleware.js b/src/js/services/lastfm/middleware.js index 708a694e..d7033ab1 100755 --- a/src/js/services/lastfm/middleware.js +++ b/src/js/services/lastfm/middleware.js @@ -1,6 +1,8 @@ +import ReactGA from 'react-ga'; import { formatUser } from '../../util/format'; const coreActions = require('../core/actions'); +const uiActions = require('../ui/actions'); const lastfmActions = require('./actions'); const LastfmMiddleware = (function () { @@ -25,6 +27,27 @@ const LastfmMiddleware = (function () { // TODO: Use callbacks for better code accuracy setTimeout(() => { store.dispatch(lastfmActions.getMe()); }, 100); + next(action); + break; + + case 'LASTFM_AUTHORIZATION_REVOKED': + if (store.getState().ui.allow_reporting) { + ReactGA.event({ category: 'LastFM', action: 'Authorization revoked' }); + } + + store.dispatch(uiActions.createNotification({ + content: 'Logout successful', + description: 'If you have shared your authorization, make sure you revoke your token', + sticky: true, + links: [ + { + url: 'https://www.last.fm/settings/applications', + text: 'Authorized apps', + new_window: true, + }, + ], + })); + next(action); break; diff --git a/src/js/services/spotify/middleware.js b/src/js/services/spotify/middleware.js index 90c60f34..b300618b 100755 --- a/src/js/services/spotify/middleware.js +++ b/src/js/services/spotify/middleware.js @@ -10,6 +10,7 @@ import { formatUser, } from '../../util/format'; const coreActions = require('../core/actions'); +const uiActions = require('../ui/actions'); const spotifyActions = require('./actions'); const pusherActions = require('../pusher/actions'); @@ -31,8 +32,21 @@ const SpotifyMiddleware = (function () { case 'SPOTIFY_AUTHORIZATION_REVOKED': if (store.getState().ui.allow_reporting) { - ReactGA.event({ category: 'Spotify', action: 'Authorization revoked' }); - } + ReactGA.event({ category: 'Spotify', action: 'Authorization revoked' }); + } + + store.dispatch(uiActions.createNotification({ + content: 'Logout successful', + description: 'If you have shared your authorization, make sure you revoke your token', + sticky: true, + links: [ + { + url: 'https://www.spotify.com/nz/account/apps/', + text: 'Authorized apps', + new_window: true, + }, + ], + })); next(action); diff --git a/src/scss/components/_notifications.scss b/src/scss/components/_notifications.scss index f69e60a3..0262e04b 100755 --- a/src/scss/components/_notifications.scss +++ b/src/scss/components/_notifications.scss @@ -29,6 +29,7 @@ &__item { margin-bottom: 0; margin-top: 5px; + font-style: inherit !important; } }