mirror of
https://github.com/ijprest/keyboard-layout-editor
synced 2024-11-13 07:10:41 +00:00
Added second GitHub client ID for local development
This commit is contained in:
parent
6a33225661
commit
f098e95e05
4
kb.js
4
kb.js
@ -25,7 +25,7 @@
|
||||
$scope.version = "0.14";
|
||||
|
||||
// Github data
|
||||
$scope.githubClientId = "631d93caeaa61c9057ab";
|
||||
$scope.githubClientId = $location.host() === "localhost" ? "8b7b224a9e212c5c17e2" : "631d93caeaa61c9057ab";
|
||||
function github(path, method, data) {
|
||||
method = method || "GET";
|
||||
var headers = {};
|
||||
@ -1242,7 +1242,7 @@
|
||||
var userLoginSecret;
|
||||
$scope.userLogin = function() {
|
||||
if(!userLoginSecret && !$scope.user) {
|
||||
var parms = "&client_id="+ $scope.githubClientId +"&redirect_uri=http://localhost:8080/oauth.html";
|
||||
var parms = "&client_id="+ $scope.githubClientId +"&redirect_uri="+ ($location.host() === "localhost" ? "http://localhost:8080/oauth.html" : "http://www.keyboard-layout-editor.com/oauth.html");
|
||||
userLoginSecret = (window.performance && window.performance.now ? window.performance.now() : Date.now()).toString() + "_" + (Math.random()).toString();
|
||||
var loginWindow = window.open("https://github.com/login/oauth/authorize?scope=gist&state="+userLoginSecret+parms,
|
||||
"Sign in with Github", "left="+(window.left+50)+",top="+(window.top+50)+",width=1050,height=630,personalbar=0,toolbar=0,scrollbars=1,resizable=1");
|
||||
|
@ -20,7 +20,11 @@ if(!window.opener) {
|
||||
var code = (window.location.href.match(/[\?\&]code=([^\&]*)/) || [null])[1];
|
||||
var state = (window.location.href.match(/[\?\&]state=([^\&]*)/) || [null])[1];
|
||||
if(code && state) {
|
||||
$.getJSON('http://kle-gatekeeper.azurewebsites.net/authenticate/'+code, function(data) {
|
||||
var gatekeeper = 'kle-gatekeeper';
|
||||
if(window.location.href.match(/^http:\/\/localhost\:/)) {
|
||||
gatekeeper += "-local";
|
||||
}
|
||||
$.getJSON('http://'+gatekeeper+'.azurewebsites.net/authenticate/'+code, function(data) {
|
||||
if(data.error) {
|
||||
window.opener.__oauthError('Gatekeeper returned an error code: ' + data.error);
|
||||
} else if(!data.token) {
|
||||
|
Loading…
Reference in New Issue
Block a user