Skip to content

Commit a764999

Browse files
authored
change JWT storage location (#93)
* change JWT storage location * v1.0.5 to the latest version
1 parent 613a96e commit a764999

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strapi-plugin-sso",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Plug-in for single sign-on with Strapi!",
55
"strapi": {
66
"displayName": "Single Sign On",

server/services/oauth.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ export default ({strapi}) => ({
8484
// get REMEMBER_ME from config
8585
const config = strapi.config.get("plugin::strapi-plugin-sso");
8686
const REMEMBER_ME = config["REMEMBER_ME"];
87-
88-
let storage = "sessionStorage";
89-
if (REMEMBER_ME) {
90-
storage = "localStorage";
91-
}
87+
const isRememberMe = !!REMEMBER_ME
9288

9389
return `
9490
<!doctype html>
@@ -99,10 +95,13 @@ export default ({strapi}) => ({
9995
</noscript>
10096
<script nonce="${nonce}">
10197
window.addEventListener('load', function() {
102-
103-
${storage}.setItem('jwtToken', '"${jwtToken}"');
104-
${storage}.setItem('userInfo', '${JSON.stringify(user)}');
105-
location.href = '${strapi.config.admin.url}'
98+
if(${isRememberMe}){
99+
localStorage.setItem('jwtToken', '"${jwtToken}"');
100+
}else{
101+
document.cookie = 'jwtToken=${encodeURIComponent(jwtToken)}; Path=/';
102+
}
103+
localStorage.setItem('isLoggedIn', 'true');
104+
location.href = '${strapi.config.admin.url}'
106105
})
107106
</script>
108107
</head>

0 commit comments

Comments
 (0)