Default auth engine (now live); Working buttons

This commit is contained in:
James Barnsley
2017-06-14 09:15:43 +12:00
parent 120ffff975
commit 3bf673b979
4 changed files with 28 additions and 25 deletions

View File

@ -4,12 +4,7 @@
// Create your application here: https://developer.spotify.com/my-applications
define('CLIENT_ID','YOUR_ID_HERE');
define('CLIENT_SECRET','YOUR_SECRET_HERE');
// Identify this script's URL
$url = (isset($_SERVER['HTTPS']) ? "https" : "http");
$url.= '://'.$_SERVER[HTTP_HOST];
$url.= explode('?',$_SERVER['REQUEST_URI'])[0];
define('URL',$url);
define('REDIRECT_URI','YOUR_REDIRECT_URI_HERE (to this file)');
// Allow cross-domain requests
header("Access-Control-Allow-Origin: *");
@ -75,7 +70,7 @@ if (isset($_GET['code'])){
} else if (isset($_GET['action']) && $_GET['action'] == 'authorize'){
// Simply redirect to the authorization panel
header('Location: https://accounts.spotify.com/authorize?client_id='.CLIENT_ID.'&redirect_uri='.URL.'&scope='.$_GET['scope'].'&response_type=code&show_dialog=true');
header('Location: https://accounts.spotify.com/authorize?client_id='.CLIENT_ID.'&redirect_uri='.REDIRECT_URI.'&scope='.$_GET['scope'].'&response_type=code&show_dialog=true');
exit;
}
@ -92,7 +87,6 @@ if (isset($_GET['code'])){
* Get a new access token
* Creates a request to Spotify, which returns a new access_token, refresh_token and token_expiry object
* @param $code = string
* @param $url = redirect url (this script)
*/
function getToken($code){
@ -106,7 +100,7 @@ function getToken($code){
'client_secret' => CLIENT_SECRET,
'grant_type' => 'authorization_code',
'code' => $code,
'redirect_uri' => URL
'redirect_uri' => REDIRECT_URI
);
curl_setopt($ch, CURLOPT_URL,"https://accounts.spotify.com/api/token");
@ -169,13 +163,4 @@ function refreshToken($refresh_token){
curl_close ($ch);
return $response;
}
}

View File

@ -2,4 +2,4 @@
enabled = true
country = NZ
locale = en_NZ
authorization_url = http://iris.barnsley.nz/auth.php
authorization_url = https://jamesbarnsley.co.nz/auth_v2.php

2
src/js/bootstrap.js vendored
View File

@ -57,7 +57,7 @@ var initialState = {
current_tltrack: false,
notifications: [],
config: {
authorization_url: 'https://jamesbarnsley.co.nz/auth.php'
authorization_url: 'https://jamesbarnsley.co.nz/auth_v2.php'
}
}
};

View File

@ -133,7 +133,7 @@ input[type="submit"] {
&.timing-out {
position: relative;
&::before {
&:before {
@include animate_timeout(2s);
content: '';
position: absolute;
@ -175,19 +175,37 @@ input[type="submit"] {
position: absolute;
display: block;
content: '';
background: rgba(0,0,0,0.15);
background: $mid_grey;
opacity: 1;
animation: slideloader 1s infinite;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 3px;
z-index: 1;
}
&.primary {
&:after {
background: $turquoise;
}
}
&.secondary {
&:after {
background: $black;
}
}
&.destructive {
&:after {
background: $red;
}
}
&.white {
&:after {
background: rgba(255,255,255,0.5);
background: $white;
}
}
}