From 007021ce11727711263e2a7413c0d0da7720bed5 Mon Sep 17 00:00:00 2001 From: valeriagrazzini Date: Thu, 15 Sep 2022 14:57:10 +0100 Subject: [PATCH 1/3] removed spotify routes and interface part --- src/controllers/account/account.router.ts | 10 - src/controllers/account/account.test.ts | 39 +-- src/controllers/oidc/oidc.router.ts | 9 - src/views/account.ejs | 401 ++++++++++------------ src/views/claim.ejs | 24 -- src/views/signin.ejs | 8 - 6 files changed, 178 insertions(+), 313 deletions(-) diff --git a/src/controllers/account/account.router.ts b/src/controllers/account/account.router.ts index 75e6a4b..9ebbf5e 100644 --- a/src/controllers/account/account.router.ts +++ b/src/controllers/account/account.router.ts @@ -13,9 +13,6 @@ import { getTwitterFollow } from './twitter/getFollow.action'; import { getYoutube } from './google/get.controller'; import { getYoutubeLike } from './google/youtube/like/get.controller'; import { getYoutubeSubscribe } from './google/youtube/subscribe/get.controller'; -import { getSpotifyUserFollow, getSpotifyPlaylistFollow } from './spotify/get.follow.action'; -import { getSpotifyTrackPlaying, getSpotifyTrackRecent, getSpotifyTrackSaved } from './spotify/get.track.action'; -import { getSpotify } from './spotify/get.action'; import { createLoginValidation, postLogin } from './login/post.controller'; const router = express.Router(); @@ -33,13 +30,6 @@ router.get('/:sub/google/youtube', guard.check(['account:read']), getYoutube); router.get('/:sub/google/youtube/like/:item', guard.check(['account:read']), getYoutubeLike); router.get('/:sub/google/youtube/subscribe/:item', guard.check(['account:read']), getYoutubeSubscribe); -router.get('/:sub/spotify', guard.check(['account:read']), getSpotify); -router.get('/:sub/spotify/user_follow/:item', guard.check(['account:read']), getSpotifyUserFollow); -router.get('/:sub/spotify/playlist_follow/:item', guard.check(['account:read']), getSpotifyPlaylistFollow); -router.get('/:sub/spotify/track_playing/:item', guard.check(['account:read']), getSpotifyTrackPlaying); -router.get('/:sub/spotify/track_recent/:item', guard.check(['account:read']), getSpotifyTrackRecent); -router.get('/:sub/spotify/track_saved/:item', guard.check(['account:read']), getSpotifyTrackSaved); - router.get('/address/:address', guard.check(['account:read']), validate([]), getAccountByAddress); router.get('/email/:email', guard.check(['account:read']), validate([]), getAccountByEmail); router.patch('/:id', guard.check(['account:read', 'account:write']), patchAccount); diff --git a/src/controllers/account/account.test.ts b/src/controllers/account/account.test.ts index 826829d..95156f3 100644 --- a/src/controllers/account/account.test.ts +++ b/src/controllers/account/account.test.ts @@ -5,7 +5,7 @@ import db from '../../util/database'; import { AccountService } from '../../services/AccountService'; import { INITIAL_ACCESS_TOKEN } from '../../util/secrets'; import { accountAddress, accountEmail, accountSecret } from '../../util/jest'; -import { SPOTIFY_API_ENDPOINT, TWITTER_API_ENDPOINT } from '../../util/secrets'; +import { TWITTER_API_ENDPOINT } from '../../util/secrets'; const http = request.agent(app); @@ -135,10 +135,6 @@ describe('Account Controller', () => { describe('GET /account/:sub/twitter', () => { beforeAll(async () => { - nock(SPOTIFY_API_ENDPOINT) - .persist() - .get(/.*?/) - .reply(200, { data: { items: [] } }); nock(TWITTER_API_ENDPOINT) .persist() .get(/.*?/) @@ -209,37 +205,4 @@ describe('Account Controller', () => { expect(res.body.isAuthorized).toEqual(true); }); }); - - describe('GET /account/:sub/spotify', () => { - it('Denice Access if there no authorization header', async () => { - const res = await http.get(`/account/${accountId}/spotify`).send(); - expect(res.status).toEqual(401); - }); - - it('Throw Error if there no linked spotify', async () => { - const res = await http - .get(`/account/${accountId}/spotify`) - .set({ - Authorization: authHeader, - }) - .send(); - expect(res.body.isAuthorized).toEqual(false); - }); - - it('Successfully get linked Spotify info with a correct infomation', async () => { - const account = await AccountService.getByEmail(accountEmail); - account.spotifyAccessToken = 'TOKEN'; - account.spotifyRefreshToken = 'REFRESH'; - account.spotifyAccessTokenExpires = (Date.now() + 1000000) * 1000; - await account.save(); - - const res = await http - .get(`/account/${accountId}/spotify`) - .set({ - Authorization: authHeader, - }) - .send(); - expect(res.body.isAuthorized).toEqual(true); - }); - }); }); diff --git a/src/controllers/oidc/oidc.router.ts b/src/controllers/oidc/oidc.router.ts index 57c32cc..3a7d66d 100644 --- a/src/controllers/oidc/oidc.router.ts +++ b/src/controllers/oidc/oidc.router.ts @@ -17,14 +17,12 @@ import CreateForgot from './forgot/post'; import CreateReset from './reset/post'; import ReadCallbackGoogle from './callback/google/get.controller'; import ReadCallbackTwitter from './callback/twitter/get.controller'; -import ReadCallbackSpotify from './callback/spotify/get.controller'; import ReadAccount from './account/get'; import UpdateAccount from './account/post'; import UpdateAccountTOTP from './account/totp/post'; import ReadAccountTOTP from './account/totp/get'; import PostGoogleDisconnect from './account/google/disconnect/post.controller'; import PostTwitterDisconnect from './account/twitter/disconnect/post.controller'; -import PostSpotifyDisconnect from './account/spotify/disconnect/post.controller'; import ReadAccountEmailVerify from './account/email/get'; import { assertInput, assertAuthorization, assertInteraction } from '../../middlewares'; @@ -32,7 +30,6 @@ const router = express.Router(); router.get('/callback/google', ReadCallbackGoogle.controller); router.get('/callback/twitter', ReadCallbackTwitter.controller); -router.get('/callback/spotify', ReadCallbackSpotify.controller); // Routes require no auth router.get('/:uid', assertInteraction, ReadOIDC.controller); @@ -57,12 +54,6 @@ router.get('/:uid/connect', assertInteraction, assertAuthorization, ReadConnect. router.get('/:uid/account', assertInteraction, assertAuthorization, ReadAccount.controller); router.post('/:uid/account/google/disconnect', assertInteraction, assertAuthorization, PostGoogleDisconnect.controller); -router.post( - '/:uid/account/spotify/disconnect', - assertInteraction, - assertAuthorization, - PostSpotifyDisconnect.controller, -); router.post( '/:uid/account/twitter/disconnect', assertInteraction, diff --git a/src/views/account.ejs b/src/views/account.ejs index 532f53b..d28e15c 100644 --- a/src/views/account.ejs +++ b/src/views/account.ejs @@ -1,229 +1,182 @@
-
- THX Logo -
-
-
- - Account - - <% if (alert && alert.message) { %> - -
- <%= alert.message %> -
+
+ THX Logo +
+
+
+ + Account + + <% if (alert && alert.message) { %> + +
+ <%= alert.message %> +
+ <% } %> +
+ + <% if (params.profileImg) { %> +
+ profle-picture +
+ <% } %> +
+
+ Profile: +
+
+ +
+
+
+
+ Email: +
+
+ +
+
+ +
+
+ Address: +
+ +
+ +
+
+ +
+
+ First name: +
+
+ +
+
+ +
+
+ Last name: +
+
+ +
+
+ +
+
+ Organisation: +
+
+ +
+
+ + <% if (params.googleAccess) { %> + + <% } %> + + <% if (params.twitterAccess) { %> + + <% } %> + + + + +
+
+ Plan +
+
+ +
+
+ + +
+
+
+
+ MFA + Multi-factor Authentication using time-based one-time passwords + (TOTP). +
+
+ <% if (params.otpSecret) { %> +
+ + +
+ <% } %> + <% if (!params.otpSecret) { %> +
+ +
+ <% } %> +
+
+
+
+
+ Connect + Link your other accounts using single sign-on. +
+ +
+
+ <% if (params.googleLoginUrl && !params.googleAccess) { %> + + <% } %> + <% if (params.googleAccess) { %> +
+ +
<% } %> -
- - <% if (params.profileImg) { %> -
- profle-picture -
- <% } %> -
-
- Profile: -
-
- -
-
-
-
- Email: -
-
- -
-
- -
-
- Address: -
- -
- -
-
- -
-
- First name: -
-
- -
-
- -
-
- Last name: -
-
- -
-
- -
-
- Organisation: -
-
- -
-
- - <% if (params.googleAccess) { %> - - <% } %> - - <% if (params.twitterAccess) { %> - - <% } %> - - <% if (params.spotifyAccess) { %> - - <% } %> - - -
-
- Plan -
-
- -
-
- - -
-
-
-
- MFA - Multi-factor Authentication using time-based one-time passwords - (TOTP). -
-
- <% if (params.otpSecret) { %> -
- - -
- <% } %> - <% if (!params.otpSecret) { %> -
- -
- <% } %> -
-
-
-
-
- Connect - Link your other accounts using single sign-on. -
- -
-
- <% if (params.googleLoginUrl && !params.googleAccess) { %> - - <% } %> - <% if (params.googleAccess) { %> -
- -
- <% } %> - <% if (params.twitterLoginUrl && !params.twitterAccess) { %> - - <% } %> - <% if (params.twitterAccess) { %> -
- -
- <% } %> - <% if (params.spotifyLoginUrl && !params.spotifyAccess) - { %> - - <% } %> - <% if (params.spotifyAccess) { %> -
- -
- <% } %> -
-
-
- -
- - - Return to application - + <% if (params.twitterLoginUrl && !params.twitterAccess) { %> + + <% } %> + <% if (params.twitterAccess) { %> +
+ +
+ <% } %> +
+
+ +
+ + + Return to application +
+
\ No newline at end of file diff --git a/src/views/claim.ejs b/src/views/claim.ejs index f57f02c..346fbf5 100644 --- a/src/views/claim.ejs +++ b/src/views/claim.ejs @@ -44,22 +44,6 @@ follow this account. <% } %> - <% if (params.channelAction == 'SpotifyUserFollow' ) { %> - follow this account. - <% } %> - <% if (params.channelAction == 'SpotifyPlaylistFollow' ) { %> - follow this playlist. - <% } %> - <% if (params.channelAction == 'SpotifyTrackPlaying' ) { %> - play this track. - <% } %> - <% if (params.channelAction == 'SpotifyTrackSaved' ) { %> - save this track. - <% } %>

Make sure to grant these scopes: @@ -87,14 +71,6 @@

Sign in with Twitter
<% } %> - <% if (params.spotifyLoginUrl ) { %> - - <% } %>
diff --git a/src/views/signin.ejs b/src/views/signin.ejs index fb311b1..d60f5d4 100644 --- a/src/views/signin.ejs +++ b/src/views/signin.ejs @@ -97,14 +97,6 @@
Sign in with Twitter
<% } %> - <% if (params.spotifyLoginUrl) { %> - - <% } %> <% if (params.authRequestMessage) { %>