@tblabs/storage 5.2.4 → 5.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/IStorageUser.d.ts
CHANGED
|
@@ -9,15 +9,18 @@ export interface IStorageUserPrivileges {
|
|
|
9
9
|
Datasets: IEntitiesSet;
|
|
10
10
|
};
|
|
11
11
|
Update: {
|
|
12
|
+
Datasets: IEntitiesSet;
|
|
12
13
|
Files: IEntitiesSet;
|
|
13
14
|
};
|
|
14
15
|
Delete: {
|
|
16
|
+
Datasets: IEntitiesSet;
|
|
15
17
|
Files: IEntitiesSet;
|
|
16
18
|
};
|
|
17
19
|
List: {
|
|
18
20
|
Datasets: IEntitiesSet;
|
|
19
21
|
};
|
|
20
22
|
Get: {
|
|
23
|
+
Datasets: IEntitiesSet;
|
|
21
24
|
Files: IEntitiesSet;
|
|
22
25
|
};
|
|
23
26
|
Drop: {
|
|
@@ -44,7 +47,10 @@ export interface IStorageUser extends ISender {
|
|
|
44
47
|
Name: string;
|
|
45
48
|
Role: string;
|
|
46
49
|
Icon: string;
|
|
50
|
+
Login: string;
|
|
47
51
|
Password: string;
|
|
52
|
+
Email: string;
|
|
48
53
|
Privileges: IStorageUserPrivileges;
|
|
49
54
|
Tags: string[];
|
|
55
|
+
CreatedAt: Date;
|
|
50
56
|
}
|
|
@@ -2,5 +2,5 @@ import { IStorageUserPrivileges } from "../IStorageUser";
|
|
|
2
2
|
import { Message } from "../MessageBus/Message";
|
|
3
3
|
import { dir } from "../Types/dir";
|
|
4
4
|
export declare class RegisterCommand extends Message {
|
|
5
|
-
constructor(Database: dir, Id: string, Role: string, Name: string, Password: string, Privileges: IStorageUserPrivileges, Icon?: string, Tags?: string[]);
|
|
5
|
+
constructor(Database: dir, Id: string, Role: string, Name: string, Login: string, Password: string, Email: string, Privileges: IStorageUserPrivileges, Icon?: string, Tags?: string[], CreatedAt?: Date);
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Message } from "../MessageBus/Message";
|
|
2
2
|
export class RegisterCommand extends Message {
|
|
3
|
-
constructor(Database, Id, Role, Name, Password, Privileges, Icon, Tags) {
|
|
4
|
-
super("Register", { Database, Id, Role,
|
|
3
|
+
constructor(Database, Id, Role, Name, Login, Password, Email, Privileges, Icon, Tags, CreatedAt) {
|
|
4
|
+
super("Register", { Database, Id, Role, Name, Login, Password, Email, Privileges, Icon, Tags, CreatedAt });
|
|
5
5
|
}
|
|
6
6
|
}
|
package/OnlineStorage.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export declare class OnlineStorage {
|
|
|
20
20
|
get User(): IStorageUser;
|
|
21
21
|
Login(password: string): Promise<IStorageUser>;
|
|
22
22
|
private SaveUserInLocalStorage;
|
|
23
|
-
OnUserChange(handler: (user: IStorageUser) => void): this;
|
|
24
|
-
Register(id: string, role: string, name: string, password: string, privileges: IStorageUserPrivileges, icon?: string, tags?: string[]): Promise<IStorageUser>;
|
|
23
|
+
OnUserChange(handler: (user: IStorageUser, isAuthorized: boolean, appStart: boolean) => void): this;
|
|
24
|
+
Register(id: string, role: string, name: string, login: string, password: string, email: string, privileges: IStorageUserPrivileges, icon?: string, tags?: string[]): Promise<IStorageUser>;
|
|
25
25
|
Logout(): this;
|
|
26
26
|
private CallOnUserChanged;
|
|
27
27
|
get IsAuthorized(): boolean;
|
package/OnlineStorage.js
CHANGED
|
@@ -18,18 +18,18 @@ export class OnlineStorage {
|
|
|
18
18
|
this.database = database;
|
|
19
19
|
this._bus = bus || new MessageBus(server, sender);
|
|
20
20
|
this.USER_LOCAL_STORAGE_KEY = "OnlineStorage:User:" + this.database;
|
|
21
|
-
this.LoadUserFromLocalStorage();
|
|
21
|
+
this.LoadUserFromLocalStorage(true);
|
|
22
22
|
}
|
|
23
23
|
IsBrowserEnvironment() {
|
|
24
24
|
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
25
25
|
}
|
|
26
|
-
LoadUserFromLocalStorage() {
|
|
26
|
+
LoadUserFromLocalStorage(appStart) {
|
|
27
27
|
if (this.IsBrowserEnvironment()) {
|
|
28
28
|
const user = window.localStorage.getItem(this.USER_LOCAL_STORAGE_KEY);
|
|
29
29
|
if (user) {
|
|
30
30
|
this.user = JSON.parse(user);
|
|
31
31
|
this.SetUser(this.user || this.ANONYMOUS_USER);
|
|
32
|
-
this.CallOnUserChanged();
|
|
32
|
+
this.CallOnUserChanged(appStart);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -44,7 +44,7 @@ export class OnlineStorage {
|
|
|
44
44
|
this.user = result.Result || this.ANONYMOUS_USER;
|
|
45
45
|
this.SetUser(this.user);
|
|
46
46
|
this.SaveUserInLocalStorage();
|
|
47
|
-
this.CallOnUserChanged();
|
|
47
|
+
this.CallOnUserChanged(false);
|
|
48
48
|
return this.user;
|
|
49
49
|
}
|
|
50
50
|
SaveUserInLocalStorage() {
|
|
@@ -54,11 +54,12 @@ export class OnlineStorage {
|
|
|
54
54
|
}
|
|
55
55
|
OnUserChange(handler) {
|
|
56
56
|
this.onUserChange.push(handler);
|
|
57
|
-
handler(this.user);
|
|
57
|
+
handler(this.user, this.IsAuthorized, true);
|
|
58
58
|
return this;
|
|
59
59
|
}
|
|
60
|
-
async Register(id, role, name, password, privileges, icon, tags) {
|
|
61
|
-
const
|
|
60
|
+
async Register(id, role, name, login, password, email, privileges, icon, tags) {
|
|
61
|
+
const createdAt = new Date();
|
|
62
|
+
const result = await this._bus.SendMessage(new RegisterCommand(this.DatabaseDir, id, role, name, login, password, email, privileges, icon, tags, createdAt));
|
|
62
63
|
if (!result.IsSuccess) {
|
|
63
64
|
throw new Error(`Could not register: ${result.ErrorMessage}`);
|
|
64
65
|
}
|
|
@@ -68,11 +69,11 @@ export class OnlineStorage {
|
|
|
68
69
|
Logout() {
|
|
69
70
|
this.SetUser(this.ANONYMOUS_USER);
|
|
70
71
|
this.SaveUserInLocalStorage();
|
|
71
|
-
this.CallOnUserChanged();
|
|
72
|
+
this.CallOnUserChanged(false);
|
|
72
73
|
return this;
|
|
73
74
|
}
|
|
74
|
-
CallOnUserChanged() {
|
|
75
|
-
this.onUserChange.forEach(handler => handler(this.user));
|
|
75
|
+
CallOnUserChanged(appStart) {
|
|
76
|
+
this.onUserChange.forEach(handler => handler(this.user, this.IsAuthorized, appStart));
|
|
76
77
|
}
|
|
77
78
|
get IsAuthorized() {
|
|
78
79
|
return this.user.Id !== this.ANONYMOUS_USER.Id;
|
|
@@ -92,7 +93,7 @@ export class OnlineStorage {
|
|
|
92
93
|
}
|
|
93
94
|
Log(...message) {
|
|
94
95
|
if (this.logEnabled) {
|
|
95
|
-
console.log('[
|
|
96
|
+
console.log('[OnlineStorage]', ...message);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
async Ping() {
|
package/package.json
CHANGED
|
Binary file
|
package/tblabs-storage-5.2.4.tgz
DELETED
|
Binary file
|