@gandalan/weblibs 1.0.15 → 1.0.17

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.
Files changed (2) hide show
  1. package/api/IDAS.js +25 -56
  2. package/package.json +1 -1
package/api/IDAS.js CHANGED
@@ -30,42 +30,33 @@ class IDAS
30
30
  this.restClient = new RESTClient(settings);
31
31
  }
32
32
 
33
- claims = {
34
- hasClaim(key) {
35
- if (!authJwtToken) {
36
- return false;
37
- }
38
-
39
- try {
40
- let decoded = jwt_decode(authJwtToken);
41
- let val = decoded[key];
42
- return val !== undefined;
43
- // eslint-disable-next-line no-empty
44
- } catch {}
45
-
46
- return false;
47
- },
48
-
49
- getClaim(key) {
50
- if (!authJwtToken) {
51
- return;
52
- }
53
-
54
- try {
55
- let decoded = jwt_decode(authJwtToken);
56
- return decoded[key];
57
- // eslint-disable-next-line no-empty
58
- } catch {}
59
-
60
- return;
61
- },
62
- }
63
-
64
33
  auth = {
65
34
  _self: this,
66
- async getCurrentAuthToken() {
67
- return await this._self.restClient.put("/Login/Update/", { Token: authToken })
68
- },
35
+ getCurrentAuthToken() {
36
+ return this._self.settings.jwtToken;
37
+ },
38
+ getRights() {
39
+ const token = this._self.settings.jwtToken;
40
+ if (!token)
41
+ return [];
42
+ const decoded = jwt_decode(authJwtToken);
43
+ return decoded.rights;
44
+ },
45
+ getRoles() {
46
+ const token = this._self.settings.jwtToken;
47
+ if (!token)
48
+ return [];
49
+ const decoded = jwt_decode(authJwtToken);
50
+ return decoded.role;
51
+ },
52
+ hasRight(code)
53
+ {
54
+ return this.getRights().some(r => r === code);
55
+ },
56
+ hasRole(code)
57
+ {
58
+ return this.getRoles().some(r => r === code);
59
+ }
69
60
  };
70
61
 
71
62
  mandanten = {
@@ -94,28 +85,6 @@ class IDAS
94
85
  },
95
86
  };
96
87
 
97
- feedback = {
98
- _self: this,
99
- async getAll() {
100
- return await this._self.restClient.get("/Feedback/");
101
- },
102
- async get(guid) {
103
- return await this._self.restClient.get(`/Feedback/${guid}`);
104
- },
105
- async save(m) {
106
- await this._self.restClient.put("/Feedback", m);
107
- },
108
- async comment(guid, commentData) {
109
- await this._self.restClient.put(`/FeedbackKommentar/${guid}`, commentData);
110
- },
111
- async attachFile(guid, filename, data) {
112
- await this._self.restClient.put(`/FeedbackAttachment/?feedbackGuid=${guid}&filename=${filename}`, data);
113
- },
114
- async deleteFile(guid) {
115
- await this._self.restClient.delete(`/FeedbackAttachment/${guid}`);
116
- },
117
- };
118
-
119
88
  rollen = {
120
89
  _self: this,
121
90
  async getAll() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "WebLibs for Gandalan JS/TS/Svelte projects",
5
5
  "keywords": [
6
6
  "gandalan"