Fix bug GitLab when not log in

This commit is contained in:
Buu Nguyen 2015-11-15 11:09:36 -08:00
parent b3d0088903
commit 26da61ebb9
2 changed files with 6 additions and 7 deletions

View File

@ -13,13 +13,13 @@ class GitLab extends Adapter {
constructor(store) {
super()
// GitLab (for now) embeds access token in the page.
// GitLab (for now) embeds access token in the page of a logged-in user.
// Use it to set the token if one isn't available.
let token = store.get(STORE.TOKEN)
const token = store.get(STORE.TOKEN)
if (!token) {
token = $('head').text().match(/gon.api_token\s*=\s*"(.*?)"/m)[1]
if (token) {
store.set(STORE.TOKEN, token, true)
const match = $('head').text().match(/gon.api_token\s*=\s*"(.*?)"/m)
if (match && match[1]) {
store.set(STORE.TOKEN, match[1])
}
}
}

View File

@ -11,8 +11,7 @@ $(document).ready(() => {
}
function createAdapter() {
var githubUrls = store.get(STORE.GHEURLS).split(/\n/).concat('github.com')
const githubUrls = store.get(STORE.GHEURLS).split(/\n/).concat('github.com')
return ~githubUrls.indexOf(location.host)
? new GitHub(store)
: new GitLab(store)