Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
feat: add logout button
Browse files Browse the repository at this point in the history
  • Loading branch information
VChet committed Oct 17, 2020
1 parent c83fea0 commit be178f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ app.use(express.static("public"));
app.use("/api", api);

app.get("/login", passport.authenticate("github", { scope: ["read:user"] }));
app.get("/logout", (req, res) => {
req.logout();
res.redirect("/");
});
app.get("/github/callback", passport.authenticate("github"), (req, res) => res.redirect("/"));

const clientIndex = path.join(__dirname, "public/index.html");
Expand Down
5 changes: 4 additions & 1 deletion src/src/components/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
<button class="link" type="button" @click="$emit('open-nav-link', 'showHowtoUseModal')">How to Use</button>
<button class="link" type="button" @click="$emit('open-nav-link', 'showAddStyleModal')">Add Style</button>
<a v-if="!user.username" href="/login">Login</a>
<button v-else class="link" type="button">{{ user.username }}</button>
<template v-else>
<button class="link" type="button">{{ user.username }}</button>
<a href="/logout">Logout</a>
</template>
</nav>
</div>
</header>
Expand Down

0 comments on commit be178f4

Please sign in to comment.