forked from cory/tildefriends
Reapply "build: Add prettier to the project"
This reverts commit 7822b30dcb
.
This commit is contained in:
parent
7822b30dcb
commit
2d3e108fd9
31
core/auth.js
31
core/auth.js
@ -54,8 +54,30 @@ function makeJwt(payload) {
|
|||||||
id = ssb.createIdentity(':auth');
|
id = ssb.createIdentity(':auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
let final_payload = b64url(base64Encode(JSON.stringify(Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval}))));
|
const final_payload = b64url(
|
||||||
let jwt = [b64url(base64Encode(JSON.stringify({alg: 'HS256', typ: 'JWT'}))), final_payload, b64url(ssb.hmacsha256sign(final_payload, ':auth', id))].join('.');
|
base64Encode(
|
||||||
|
JSON.stringify(
|
||||||
|
Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const jwt = [
|
||||||
|
b64url(
|
||||||
|
base64Encode(
|
||||||
|
JSON.stringify({
|
||||||
|
alg: 'HS256',
|
||||||
|
typ: 'JWT'
|
||||||
|
})
|
||||||
|
)
|
||||||
|
),
|
||||||
|
final_payload,
|
||||||
|
b64url(
|
||||||
|
ssb.hmacsha256sign(final_payload, ':auth', id)
|
||||||
|
)
|
||||||
|
].join('.');
|
||||||
|
|
||||||
return jwt;
|
return jwt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +141,9 @@ function hashPassword(password) {
|
|||||||
* @returns TODOC
|
* @returns TODOC
|
||||||
*/
|
*/
|
||||||
function noAdministrator() {
|
function noAdministrator() {
|
||||||
return !core.globalSettings || !core.globalSettings.permissions || !Object.keys(core.globalSettings.permissions).some(function(name) {
|
return !core.globalSettings ||
|
||||||
|
!core.globalSettings.permissions ||
|
||||||
|
!Object.keys(core.globalSettings.permissions).some(function(name) {
|
||||||
return core.globalSettings.permissions[name].indexOf("administration") != -1;
|
return core.globalSettings.permissions[name].indexOf("administration") != -1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -183,6 +207,7 @@ function isNameValid(name) {
|
|||||||
function handler(request, response) {
|
function handler(request, response) {
|
||||||
// TODO(tasiaiso): split this function
|
// TODO(tasiaiso): split this function
|
||||||
let session = getCookies(request.headers).session;
|
let session = getCookies(request.headers).session;
|
||||||
|
|
||||||
if (request.uri == "/login") {
|
if (request.uri == "/login") {
|
||||||
let formData = form.decodeForm(request.query);
|
let formData = form.decodeForm(request.query);
|
||||||
if (query(request.headers)?.permissions?.authenticated) {
|
if (query(request.headers)?.permissions?.authenticated) {
|
||||||
|
Loading…
Reference in New Issue
Block a user