Skip to content

Commit bac3fdf

Browse files
committed
Token Expired Problem Fixed
1 parent 4aec56c commit bac3fdf

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

templates/base.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@
8282
console.log(user.email)
8383
console.log(user.uid)
8484
document.getElementById("sign-out").style.display="block";
85+
user.getIdToken().then(function (token) {
86+
// Add the token to the browser's cookies. The server will then be
87+
// able to verify the token against the API.
88+
// SECURITY NOTE: As cookies can easily be modified, only put the
89+
// token (which is verified server-side) in a cookie; do not add other
90+
// user information.
91+
document.cookie = "token=" + token;
92+
});
8593
} else {
8694
console.log("No user signed in")
8795
}

templates/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ <h2>Login info:</h2>
111111
ui.reset();
112112
document.getElementById('login-info').style.display = 'block';
113113
document.getElementById('sign-out').style.display = 'block';
114+
user.getIdToken().then(function (token) {
115+
// Add the token to the browser's cookies. The server will then be
116+
// able to verify the token against the API.
117+
// SECURITY NOTE: As cookies can easily be modified, only put the
118+
// token (which is verified server-side) in a cookie; do not add other
119+
// user information.
120+
document.cookie = "token=" + token;
121+
});
114122
} else {
115123
// No user signed in, render sign-in UI.
116124
ui.start('#firebaseui-auth-container', uiConfig);

0 commit comments

Comments
 (0)