|
|
@ -523,6 +523,25 @@ export const saveGitHubCredentials = async (credentials: { username: string, ema |
|
|
|
if (storedEmail !== credentials.email) await plugin.call('config', 'setAppParameter', 'settings/github-email', credentials.email) |
|
|
|
if (storedEmail !== credentials.email) await plugin.call('config', 'setAppParameter', 'settings/github-email', credentials.email) |
|
|
|
if (storedToken !== credentials.token) await plugin.call('config', 'setAppParameter', 'settings/gist-access-token', credentials.token) |
|
|
|
if (storedToken !== credentials.token) await plugin.call('config', 'setAppParameter', 'settings/gist-access-token', credentials.token) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const userFetched = await loadGitHubUserFromToken() |
|
|
|
|
|
|
|
if (!userFetched) { |
|
|
|
|
|
|
|
if (credentials.username && credentials.email) { |
|
|
|
|
|
|
|
await plugin.call('notification', 'alert', { |
|
|
|
|
|
|
|
title: 'Error', |
|
|
|
|
|
|
|
message: `Could not retreive the user from GitHub. You can continue to use the app, but you will not be able to push or pull.` |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
dispatch(setGitHubUser({ |
|
|
|
|
|
|
|
login: credentials.username, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
dispatch(setUserEmails([{ |
|
|
|
|
|
|
|
email: credentials.email, |
|
|
|
|
|
|
|
primary: true, |
|
|
|
|
|
|
|
verified: null, |
|
|
|
|
|
|
|
visibility: null |
|
|
|
|
|
|
|
}])) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
} |
|
|
|
} |
|
|
@ -578,12 +597,14 @@ export const loadGitHubUserFromToken = async () => { |
|
|
|
type: 'success', |
|
|
|
type: 'success', |
|
|
|
message: `Github user loaded...` |
|
|
|
message: `Github user loaded...` |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
return true |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
sendToGitLog({ |
|
|
|
sendToGitLog({ |
|
|
|
type: 'error', |
|
|
|
type: 'error', |
|
|
|
message: `Please check your GitHub token in the GitHub settings.` |
|
|
|
message: `Please check your GitHub token in the GitHub settings.` |
|
|
|
}) |
|
|
|
}) |
|
|
|
dispatch(setGitHubUser(null)) |
|
|
|
dispatch(setGitHubUser(null)) |
|
|
|
|
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
sendToGitLog({ |
|
|
|
sendToGitLog({ |
|
|
@ -591,9 +612,11 @@ export const loadGitHubUserFromToken = async () => { |
|
|
|
message: `Please check your GitHub token in the GitHub settings.` |
|
|
|
message: `Please check your GitHub token in the GitHub settings.` |
|
|
|
}) |
|
|
|
}) |
|
|
|
dispatch(setGitHubUser(null)) |
|
|
|
dispatch(setGitHubUser(null)) |
|
|
|
|
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
|
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|