MCPcopy Index your code
hub / github.com/Soundnode/soundnode-app / authenticateUser

Function authenticateUser

main.js:40–71  ·  view source on GitHub ↗

* User config file doesn't exists * therefore open soundcloud authentication page

()

Source from the content-addressed store, hash-verified

38 * therefore open soundcloud authentication page
39 */
40function authenticateUser() {
41 let contents;
42
43 authenticationWindow = new BrowserWindow({
44 width: 600,
45 height: 600,
46 frame: false,
47 webPreferences: {
48 nodeIntegration: false,
49 webSecurity: false
50 }
51 });
52 authenticationWindow.loadURL(SCconnect);
53 authenticationWindow.show();
54
55 contents = authenticationWindow.webContents;
56
57 contents.on('did-get-redirect-request', (event, oldUrl, newUrl) => {
58 const access_tokenStr = 'access_token=';
59 const expires_inStr = '&expires_in';
60 let accessToken;
61
62 if (newUrl.indexOf('access_token=') < 0) {
63 return false;
64 }
65
66 accessToken = newUrl.substring(newUrl.indexOf(access_tokenStr) + 13, newUrl.indexOf(expires_inStr));
67
68 setUserData(accessToken);
69 authenticationWindow.destroy();
70 });
71}
72
73function setUserData(accessToken) {
74 fs.writeFileSync(configuration.getPath(), JSON.stringify({

Callers 1

checkUserConfigFunction · 0.85

Calls 1

setUserDataFunction · 0.85

Tested by

no test coverage detected