Skip to content

Commit

Permalink
redirect and load token in home
Browse files Browse the repository at this point in the history
  • Loading branch information
Omarabdul3ziz committed Sep 19, 2021
1 parent ada2b2d commit f8a14e3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions services/client/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const routes = [
path: "/todo",
name: "Todo",
component: Todo,
// meta: {
// requiresAuth: true,
// },
meta: {
requiresAuth: true,
},
},
{
path: "/login",
Expand Down
14 changes: 14 additions & 0 deletions services/client/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@
</template>

<script>
import Vue from "vue";
import VueCookie from "vue-cookie";
Vue.use(VueCookie);
export default {
name: "Home",
beforeCreate() {
var token = this.$cookie.get("access_token_cookie");
console.log(token);
// add to local storage
localStorage.setItem("access_token", token); // token stores in cookies
// update the store state token
this.$store.commit("updateToken", token);
},
};
</script>
2 changes: 1 addition & 1 deletion services/server/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def callback():
# create and respond with token
access_token = create_access_token(identity=username)

response = make_response(redirect("http://127.0.0.1:8080/todo"))
response = make_response(redirect("http://127.0.0.1:8080/"))
response.set_cookie("access_token_cookie", access_token)
return response

Expand Down

0 comments on commit f8a14e3

Please sign in to comment.