-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from graasp/303/signInSignOutActions
feat: add signin and signout actions, refactor dashboard
- Loading branch information
Showing
14 changed files
with
229 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
const { app } = require('electron'); | ||
const low = require('lowdb'); | ||
const FileSync = require('lowdb/adapters/FileSync'); | ||
const postAction = require('./postAction'); | ||
const { USER_COLLECTION } = require('../db'); | ||
const { DATABASE_PATH, ACTIONS_VERBS } = require('../config/config'); | ||
|
||
const windowAllClosed = mainWindow => { | ||
const adapter = new FileSync(DATABASE_PATH); | ||
const db = low(adapter); | ||
const user = db.get(USER_COLLECTION).value(); | ||
|
||
// post sign out action if user is still connected when quitting the app | ||
if (user) { | ||
const { id: userId, username, anonymous, geolocation } = user; | ||
postAction(mainWindow, db)(null, { | ||
userId, | ||
verb: ACTIONS_VERBS.LOGOUT, | ||
data: { id: userId, username, anonymous }, | ||
geolocation, | ||
}); | ||
} | ||
|
||
app.quit(); | ||
}; | ||
|
||
module.exports = windowAllClosed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.