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:
Rish 2018-11-12 08:29:54 +05:30 committed by Fabien O'Carroll
parent 32ee16a081
commit 7366f6bf4c
3 changed files with 1024 additions and 4 deletions

View File

@ -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);
}
}
};

View File

@ -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

File diff suppressed because it is too large Load Diff