Files
Trilium/src/entities/api_token.js

34 lines
981 B
JavaScript
Raw Normal View History

2018-04-01 17:38:24 -04:00
"use strict";
const Entity = require('./entity');
2018-04-02 20:46:46 -04:00
const dateUtils = require('../services/date_utils');
2018-04-01 17:38:24 -04:00
2018-08-22 23:37:06 +02:00
/**
* ApiToken is an entity representing token used to authenticate against Trilium API from client applications. Currently used only by Trilium Sender.
*
2019-11-09 09:36:08 +01:00
* @property {string} apiTokenId - primary key
* @property {string} token
* @property {boolean} isDeleted - true if API token is deleted
* @property {string} utcDateCreated
2018-08-22 23:37:06 +02:00
*
* @extends Entity
*/
2018-04-01 17:38:24 -04:00
class ApiToken extends Entity {
static get entityName() { return "api_tokens"; }
2018-04-01 17:38:24 -04:00
static get primaryKeyName() { return "apiTokenId"; }
2019-03-12 20:58:31 +01:00
static get hashedProperties() { return ["apiTokenId", "token", "utcDateCreated", "isDeleted"]; }
2018-04-01 17:38:24 -04:00
beforeSaving() {
if (!this.isDeleted) {
this.isDeleted = false;
}
2019-03-12 20:58:31 +01:00
if (!this.utcDateCreated) {
this.utcDateCreated = dateUtils.utcNowDateTime();
2018-04-01 17:38:24 -04:00
}
super.beforeSaving();
2018-04-01 17:38:24 -04:00
}
}
module.exports = ApiToken;