mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) add minimal support for activation keys
Summary: For grist-ee, expect an activation key in environment variable `GRIST_ACTIVATION` or in a file pointed to by `GRIST_ACTIVATION_FILE`. In absence of key, start a 30-day trial, during which a banner is shown. Once trial expires, installation goes into document-read-only mode. Test Plan: added a test Reviewers: dsagal Reviewed By: dsagal Subscribers: jarek Differential Revision: https://phab.getgrist.com/D3426
This commit is contained in:
28
app/gen-server/lib/Activations.ts
Normal file
28
app/gen-server/lib/Activations.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { makeId } from 'app/server/lib/idUtils';
|
||||
import { Activation } from 'app/gen-server/entity/Activation';
|
||||
import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager';
|
||||
|
||||
/**
|
||||
* Manage activations. Not much to do currently, there is at most one
|
||||
* activation. The activation singleton establishes an id and creation
|
||||
* time for the installation.
|
||||
*/
|
||||
export class Activations {
|
||||
constructor(private _db: HomeDBManager) {
|
||||
}
|
||||
|
||||
// Get the current activation row, creating one if necessary.
|
||||
// It will be created with an empty key column, which will get
|
||||
// filled in once an activation key is presented.
|
||||
public current(): Promise<Activation> {
|
||||
return this._db.connection.manager.transaction(async manager => {
|
||||
let activation = await manager.findOne(Activation);
|
||||
if (!activation) {
|
||||
activation = manager.create(Activation);
|
||||
activation.id = makeId();
|
||||
await activation.save();
|
||||
}
|
||||
return activation;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user