Skip to content
Snippets Groups Projects
Commit 0b5630d2 authored by Daniel Kovacs's avatar Daniel Kovacs
Browse files

Login fix

parent e99d2205
Branches
No related tags found
No related merge requests found
...@@ -42,7 +42,8 @@ app.get('/login', function (req, res) { ...@@ -42,7 +42,8 @@ app.get('/login', function (req, res) {
response_type: 'code', response_type: 'code',
client_id: process.env.SPOTIFY_CLIENT_ID, client_id: process.env.SPOTIFY_CLIENT_ID,
scope: 'user-read-private user-read-email playlist-modify-public playlist-modify-private', scope: 'user-read-private user-read-email playlist-modify-public playlist-modify-private',
redirect_uri: redirect_uri+encodeURI('?from='+req.query.from) redirect_uri: redirect_uri,
state: req.query.from
})) }))
}); });
...@@ -69,8 +70,8 @@ app.get('/callback', function (req, res) { ...@@ -69,8 +70,8 @@ app.get('/callback', function (req, res) {
console.log(access_token); console.log(access_token);
let uri = process.env.FRONTEND_URI || 'http://localhost:3000/' let uri = process.env.FRONTEND_URI || 'http://localhost:3000/'
uri= uri + '?access_token=' + access_token uri= uri + '?access_token=' + access_token
if (!!req.query.from){ if (!!req.query.state){
uri=uri+`&from=${req.query.from}` uri=uri+`&from=${req.query.state}`
} }
res.redirect(uri + '?access_token=' + access_token) res.redirect(uri + '?access_token=' + access_token)
}) })
......
...@@ -7,8 +7,8 @@ class Landing extends Component{ ...@@ -7,8 +7,8 @@ class Landing extends Component{
componentDidMount(){ componentDidMount(){
if(this.props.auth.isAuthenticated){ if(this.props.auth.isAuthenticated){
console.log(this.props.location.search); console.log(this.props);
this.props.history.push(`/${this.props.location.search}`); this.props.history.push(`/`);
} else { } else {
const {access_token} = queryString.parse(window.location.search); const {access_token} = queryString.parse(window.location.search);
if (access_token) this.props.loginUser(access_token); if (access_token) this.props.loginUser(access_token);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment