mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 03:46:37 +01:00
ETAPI auth, spec improvements etc.
This commit is contained in:
@@ -10,8 +10,8 @@ const appInfo = require('../../services/app_info');
|
||||
const eventService = require('../../services/events');
|
||||
const sqlInit = require('../../services/sql_init');
|
||||
const sql = require('../../services/sql');
|
||||
const ApiToken = require('../../becca/entities/api_token');
|
||||
const ws = require("../../services/ws");
|
||||
const etapiTokenService = require("../../services/etapi_tokens");
|
||||
|
||||
function loginSync(req) {
|
||||
if (!sqlInit.schemaExists()) {
|
||||
@@ -90,15 +90,12 @@ function token(req) {
|
||||
return [401, "Incorrect password"];
|
||||
}
|
||||
|
||||
const apiToken = new ApiToken({
|
||||
// for backwards compatibility with Sender which does not send the name
|
||||
name: req.body.tokenName || "Trilium Sender",
|
||||
token: utils.randomSecureToken()
|
||||
}).save();
|
||||
// for backwards compatibility with Sender which does not send the name
|
||||
const tokenName = req.body.tokenName || "Trilium Sender / Web Clipper";
|
||||
|
||||
const {authToken} = etapiTokenService.createToken(tokenName);
|
||||
|
||||
return {
|
||||
token: apiToken.token
|
||||
};
|
||||
return { token: authToken };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user