mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Updated members layer1 to handle create/destroy/get jwt token
closes #11 - Uses signed jwt with NONE algorithm - Token stored in localStorage
This commit is contained in:
parent
32ee16a081
commit
7366f6bf4c
@ -1,15 +1,22 @@
|
||||
const jwt = require('jsonwebtoken');
|
||||
const store = window.localStorage;
|
||||
|
||||
const create = (options) => {
|
||||
return {
|
||||
getToken() {
|
||||
return Promise.resolve();
|
||||
let token = store.getItem('members-token') || null;
|
||||
return Promise.resolve(token);
|
||||
},
|
||||
|
||||
login() {
|
||||
return Promise.resolve();
|
||||
let token = jwt.sign({}, null, {algorithms: ['none']});
|
||||
store.setItem('members-token', token);
|
||||
return Promise.resolve(!!token);
|
||||
},
|
||||
|
||||
logout() {
|
||||
return Promise.resolve();
|
||||
store.setItem('members-token', null);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -20,6 +20,7 @@
|
||||
"sinon": "7.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ghost-ignition": "^2.9.6"
|
||||
"ghost-ignition": "^2.9.6",
|
||||
"jsonwebtoken": "^8.3.0"
|
||||
}
|
||||
}
|
||||
|
1012
ghost/sdk/layer1/yarn.lock
Normal file
1012
ghost/sdk/layer1/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user