Commit d184e756 authored by Amy Yan's avatar Amy Yan

switched to using keytar for token storage

parent 61ec76cf
This diff is collapsed.
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"axios": "^0.19.2", "axios": "^0.19.2",
"core-js": "^3.6.4", "core-js": "^3.6.4",
"glob": "^7.1.6", "glob": "^7.1.6",
"keytar": "^7.2.0",
"md5-file": "^5.0.0", "md5-file": "^5.0.0",
"moment": "^2.27.0", "moment": "^2.27.0",
"ncp": "^2.0.0", "ncp": "^2.0.0",
......
...@@ -6,6 +6,7 @@ const http = require('http'); ...@@ -6,6 +6,7 @@ const http = require('http');
const https = require('https'); const https = require('https');
const path = require('path'); const path = require('path');
const uniqid = require('uniqid'); const uniqid = require('uniqid');
const keytar = require('keytar')
let win; let win;
let deeplinkingData; let deeplinkingData;
...@@ -210,4 +211,8 @@ function download(url, fileName, cb) { ...@@ -210,4 +211,8 @@ function download(url, fileName, cb) {
fs.unlink(dest); fs.unlink(dest);
if (cb) cb(err.message, dest); if (cb) cb(err.message, dest);
}); });
}; };
\ No newline at end of file
ipcMain.on("setToken", (event, ipcData) => {
keytar.setPassword('Spinshare', 'ConnectToken', ipcData.ConnectToken);
})
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
import Loading from '@/components/Loading.vue'; import Loading from '@/components/Loading.vue';
import { remote, ipcRenderer } from 'electron';
import keytar from 'keytar';
export default { export default {
name: 'Login', name: 'Login',
components: { components: {
...@@ -42,14 +45,16 @@ ...@@ -42,14 +45,16 @@
apiLoginServerError: false apiLoginServerError: false
} }
}, },
mounted: function() { mounted: async function() {
let ssapi = new SSAPI(); let ssapi = new SSAPI();
let userSettings = new UserSettings(); let userSettings = new UserSettings();
if(!userSettings.get("connectToken")) { let token = await keytar.findPassword('Spinshare');
if(!token) {
this.showLoginBox(); this.showLoginBox();
} else { } else {
ssapi.validateConnectToken(userSettings.get("connectToken")).then((data) => { ssapi.validateConnectToken(token).then((data) => {
if(data) { if(data) {
this.$router.replace({ name: 'StartupFrontpage' }); this.$router.replace({ name: 'StartupFrontpage' });
} else { } else {
...@@ -79,7 +84,9 @@ ...@@ -79,7 +84,9 @@
switch(data.status) { switch(data.status) {
case 200: case 200:
// Successfull // Successfull
userSettings.set("connectToken", data.data); ipcRenderer.send("setToken", {
ConnectToken: data.data
});
this.$router.replace({ name: 'StartupFrontpage' }); this.$router.replace({ name: 'StartupFrontpage' });
break; break;
case 403: case 403:
...@@ -98,6 +105,9 @@ ...@@ -98,6 +105,9 @@
this.$data.apiLoginLoading = false; this.$data.apiLoginLoading = false;
this.$data.apiLoginCodeError = false; this.$data.apiLoginCodeError = false;
this.$data.apiLoginServerError = false; this.$data.apiLoginServerError = false;
},
getCredentialFromStore: async function() {
return await keytar.findPassword('Spinshare');
} }
}, },
watch: { watch: {
......
...@@ -26,7 +26,8 @@ module.exports = { ...@@ -26,7 +26,8 @@ module.exports = {
dmg: { dmg: {
backgroundColor: "#212629" backgroundColor: "#212629"
} }
} },
externals: ['keytar']
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment