Added GitHub restricted access option in settings. Fixes #248
This commit is contained in:
parent
fcb54b196e
commit
e4a1b4536d
@ -11,10 +11,11 @@
|
||||
}
|
||||
}
|
||||
var client_id = getParameter("client_id");
|
||||
var scope = getParameter("scope") || 'repo,gist';
|
||||
var code = getParameter("code");
|
||||
if (client_id) {
|
||||
window.location.href = "https://github.com/login/oauth/authorize?client_id="
|
||||
+ client_id + "&scope=repo,gist";
|
||||
+ client_id + "&scope=" + scope;
|
||||
} else {
|
||||
if (code) {
|
||||
localStorage["githubCode"] = code;
|
||||
|
@ -137,6 +137,8 @@ define([
|
||||
utils.setInputChecked("#input-settings-gdrive-full-access", settings.gdriveFullAccess);
|
||||
// Dropbox full access
|
||||
utils.setInputChecked("#input-settings-dropbox-full-access", settings.dropboxFullAccess);
|
||||
// GitHub full access
|
||||
utils.setInputChecked("#input-settings-github-full-access", settings.githubFullAccess);
|
||||
// Template
|
||||
utils.setInputValue("#textarea-settings-publish-template", settings.template);
|
||||
// PDF template
|
||||
@ -181,6 +183,8 @@ define([
|
||||
newSettings.gdriveFullAccess = utils.getInputChecked("#input-settings-gdrive-full-access");
|
||||
// Drobox full access
|
||||
newSettings.dropboxFullAccess = utils.getInputChecked("#input-settings-dropbox-full-access");
|
||||
// GitHub full access
|
||||
newSettings.githubFullAccess = utils.getInputChecked("#input-settings-github-full-access");
|
||||
// Template
|
||||
newSettings.template = utils.getInputTextValue("#textarea-settings-publish-template", event);
|
||||
// PDF template
|
||||
|
@ -6,9 +6,10 @@ define([
|
||||
"utils",
|
||||
"storage",
|
||||
"logger",
|
||||
"settings",
|
||||
"eventMgr",
|
||||
"classes/AsyncTask",
|
||||
], function($, constants, core, utils, storage, logger, eventMgr, AsyncTask) {
|
||||
], function($, constants, core, utils, storage, logger, settings, eventMgr, AsyncTask) {
|
||||
|
||||
var connected;
|
||||
var github;
|
||||
@ -81,7 +82,8 @@ define([
|
||||
}
|
||||
function getCode() {
|
||||
storage.removeItem("githubCode");
|
||||
authWindow = utils.popupWindow('html/github-oauth-client.html?client_id=' + constants.GITHUB_CLIENT_ID, 'stackedit-github-oauth', 960, 600);
|
||||
var scope = settings.githubFullAccess ? 'repo,gist' : 'public_repo,gist';
|
||||
authWindow = utils.popupWindow('html/github-oauth-client.html?client_id=' + constants.GITHUB_CLIENT_ID + '&scope=' + scope, 'stackedit-github-oauth', 960, 600);
|
||||
authWindow.focus();
|
||||
intervalId = setInterval(function() {
|
||||
if(authWindow.closed === true) {
|
||||
|
@ -72,8 +72,10 @@ define([
|
||||
}
|
||||
window.delayedFunction = function() {
|
||||
gapi.load("client,drive-realtime", function() {
|
||||
connected = true;
|
||||
task.chain();
|
||||
gapi.client.load('drive', 'v2', function() {
|
||||
connected = true;
|
||||
task.chain();
|
||||
});
|
||||
});
|
||||
};
|
||||
$.ajax({
|
||||
@ -115,15 +117,6 @@ define([
|
||||
task.onRun(function() {
|
||||
var currentToken = gapi.auth.getToken();
|
||||
var newToken;
|
||||
function loadGdriveClient() {
|
||||
if(gapi.client.drive) {
|
||||
task.chain();
|
||||
return;
|
||||
}
|
||||
gapi.client.load('drive', 'v2', function() {
|
||||
task.chain();
|
||||
});
|
||||
}
|
||||
function getTokenInfo() {
|
||||
$.ajax({
|
||||
url: 'https://www.googleapis.com/oauth2/v1/tokeninfo',
|
||||
@ -141,7 +134,7 @@ define([
|
||||
authorizationMgr.setUserId(data.user_id);
|
||||
authorizationMgr.add(permission);
|
||||
authorizationMgr.token = newToken;
|
||||
task.chain(loadGdriveClient);
|
||||
task.chain();
|
||||
}
|
||||
}).fail(function(jqXHR) {
|
||||
var error = {
|
||||
|
@ -1013,7 +1013,7 @@
|
||||
<label>
|
||||
<input type="checkbox" id="input-settings-gdrive-full-access" />
|
||||
Allow StackEdit to open any document in Google Drive
|
||||
</label> <span class="help-block">Any existing token has to be revoked in
|
||||
</label> <span class="help-block">Existing authorization has to be revoked in
|
||||
<a href="https://www.google.com/settings/dashboard" target="_blank">Google Dashboard</a>
|
||||
for this change to take effect.</span>
|
||||
</div>
|
||||
@ -1031,6 +1031,35 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-4"></div>
|
||||
<div class="col-lg-7">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="input-settings-github-full-access" />
|
||||
Allow StackEdit to access private repositories in GitHub
|
||||
</label> <span class="help-block">Existing authorization has to be revoked in
|
||||
<a href="https://github.com/settings/applications" target="_blank">GitHub settings</a>
|
||||
for this change to take effect.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-4 control-label"
|
||||
for="input-settings-publish-commit-msg">GitHub commit message</label>
|
||||
<div class="col-lg-7">
|
||||
<input type="text" id="input-settings-publish-commit-msg"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-4 control-label"
|
||||
for="input-settings-ssh-proxy">SSH proxy</label>
|
||||
<div class="col-lg-7">
|
||||
<input type="text" id="input-settings-ssh-proxy"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-4 control-label"
|
||||
for="textarea-settings-publish-template">Default
|
||||
@ -1062,22 +1091,6 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-4 control-label"
|
||||
for="input-settings-publish-commit-msg">GitHub commit message</label>
|
||||
<div class="col-lg-7">
|
||||
<input type="text" id="input-settings-publish-commit-msg"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-4 control-label"
|
||||
for="input-settings-ssh-proxy">SSH proxy</label>
|
||||
<div class="col-lg-7">
|
||||
<input type="text" id="input-settings-ssh-proxy"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabpane-settings-shortcuts">
|
||||
|
@ -15,6 +15,7 @@ define([
|
||||
gdriveMultiAccount: 1,
|
||||
gdriveFullAccess: true,
|
||||
dropboxFullAccess: true,
|
||||
githubFullAccess: true,
|
||||
template: [
|
||||
'<!DOCTYPE html>\n',
|
||||
'<html>\n',
|
||||
|
Loading…
Reference in New Issue
Block a user