Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
current_user,
login_user,
login_required,
logout_user,
)
from flask_sqlalchemy import SQLAlchemy
from github import Github
Expand Down Expand Up @@ -285,6 +286,15 @@ def get_me():
)


@app.route("/api/logout")
def logout():
"""Logout the current user."""
logout_user()
return Response(
json.dumps({"is_authenticated": False}),
mimetype="application/json"
)

def is_github_blob(url: str) -> bool:
splits = url.split("/")
return (
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
</v-menu>

<v-btn variant="text" href="https://github.com/gorse-io/gitrec" target="_blank" color="white" icon="mdi-github" />
<v-btn variant="text" color="white" icon="mdi-logout" @click="logout" />
</div>
</v-container>

Expand Down Expand Up @@ -104,6 +105,8 @@
</template>

<script>
import axios from "axios";

export default {
data() {
return {
Expand Down Expand Up @@ -173,6 +176,15 @@ export default {
topicLabel(topic) {
return topic.replace("-", " ").toUpperCase();
},
async logout() {
try {
await axios.get("/api/logout");
localStorage.removeItem("gitrec_auth_state");
this.$router.push("/login");
} catch (error) {
console.error("Logout failed:", error);
}
},
},
};
</script>
Expand Down
Loading