Skip to content

Commit

Permalink
If someone was logged in last time, log them back in. (#367)
Browse files Browse the repository at this point in the history
* If someone was logged in last time, log them back in.

* add cookie check on logout

Co-authored-by: Nate Foss <[email protected]>
  • Loading branch information
miriam-rittenberg and npfoss authored Feb 6, 2020
1 parent 434009c commit 5874581
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/Auth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,15 @@ export default {
methods: {
loginUser: function (event) {
window.location.href = `${process.env.FIREROAD_URL}/login/?redirect=${process.env.APP_URL}`;
if (this.cookiesAllowed) {
this.$cookies.set('hasLoggedIn', true);
}
},
logoutUser: function (event) {
this.$cookies.remove('accessInfo');
if (this.cookiesAllowed) {
this.$cookies.set('hasLoggedIn', false);
}
localStorage.clear();
this.loggedIn = false;
this.accessInfo = undefined;
Expand Down Expand Up @@ -377,6 +383,8 @@ export default {
const code = queryObject['code'];
window.history.pushState('CourseRoad Home', 'CourseRoad Home', './#' + this.activeRoad);
this.getAuthorizationToken(code);
} else if (this.$cookies.get('hasLoggedIn') === 'true' && !this.loggedIn) {
this.loginUser();
}
},
save: function (roadID) {
Expand Down

0 comments on commit 5874581

Please sign in to comment.