Skip to content

Commit

Permalink
Session now fully functioning - can also logout
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Weeks authored and Sarah Weeks committed Feb 28, 2020
1 parent 3895b3d commit 499a777
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
19 changes: 19 additions & 0 deletions lib/getSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const session = require("../models/session");

function getSessions(userID) {
return new Promise((resolve, reject) => {
session.find({}, (err, docs) => {
for (const session of docs) {
console.log(session);
if (JSON.parse(session.session).userID == userID) {
resolve(true);
return;
}
}
resolve(false);
return;
})
})
}

module.exports = getSessions;
7 changes: 5 additions & 2 deletions views/account.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@

</div>
<br>
<div>
<form action="/logout" method="POST">
<input class="logout" type="submit" value="Log Out">
</form>
{{!-- <div>
<ul>
<li class="logout"><a href="/login">Log Out</a> </li>
</ul>
</div>
</div> --}}
</div>

</div>
2 changes: 1 addition & 1 deletion views/index.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="contentContainer">


{{logout}}
</div>

0 comments on commit 499a777

Please sign in to comment.