Added expiry check for frontend
Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
parent
05443f9bb7
commit
cd796898d0
|
@ -1,19 +1,19 @@
|
||||||
const { BeanModel } = require("redbean-node/dist/bean-model");
|
const { BeanModel } = require("redbean-node/dist/bean-model");
|
||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
|
const dayjs = require("dayjs");
|
||||||
|
|
||||||
class APIKey extends BeanModel {
|
class APIKey extends BeanModel {
|
||||||
/**
|
/**
|
||||||
* Get the current status of this API key
|
* Get the current status of this API key
|
||||||
*/
|
*/
|
||||||
getStatus() {
|
getStatus() {
|
||||||
let expired = false;
|
let current = dayjs();
|
||||||
if (expired) {
|
let expiry = dayjs(this.expires);
|
||||||
|
if (expiry.diff(current) < 0) {
|
||||||
return "expired";
|
return "expired";
|
||||||
} else if (this.active) {
|
|
||||||
return "active";
|
|
||||||
} else if (!this.active) {
|
|
||||||
return "inactive";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.active ? "active" : "inactive";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue