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');
|
||||
}
|
||||
|
||||
let final_payload = b64url(base64Encode(JSON.stringify(Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval}))));
|
||||
let jwt = [b64url(base64Encode(JSON.stringify({alg: 'HS256', typ: 'JWT'}))), final_payload, b64url(ssb.hmacsha256sign(final_payload, ':auth', id))].join('.');
|
||||
const final_payload = b64url(
|
||||
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;
|
||||
}
|
||||
|
||||
@ -119,7 +141,9 @@ function hashPassword(password) {
|
||||
* @returns TODOC
|
||||
*/
|
||||
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;
|
||||
});
|
||||
}
|
||||
@ -183,6 +207,7 @@ function isNameValid(name) {
|
||||
function handler(request, response) {
|
||||
// TODO(tasiaiso): split this function
|
||||
let session = getCookies(request.headers).session;
|
||||
|
||||
if (request.uri == "/login") {
|
||||
let formData = form.decodeForm(request.query);
|
||||
if (query(request.headers)?.permissions?.authenticated) {
|
||||
|
Loading…
Reference in New Issue
Block a user