5htp-core 0.6.0-96 → 0.6.0-98
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/common/errors/index.tsx
CHANGED
|
@@ -161,6 +161,21 @@ export class AuthRequired extends CoreError {
|
|
|
161
161
|
public http = 401;
|
|
162
162
|
public title = "Authentication Required";
|
|
163
163
|
public static msgDefaut = "Please Login to Continue.";
|
|
164
|
+
|
|
165
|
+
public constructor(
|
|
166
|
+
message: string,
|
|
167
|
+
public motivation?: string,
|
|
168
|
+
details?: TErrorDetails
|
|
169
|
+
) {
|
|
170
|
+
super(message, details);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public json(): TJsonError & { motivation?: string } {
|
|
174
|
+
return {
|
|
175
|
+
...super.json(),
|
|
176
|
+
motivation: this.motivation,
|
|
177
|
+
}
|
|
178
|
+
}
|
|
164
179
|
}
|
|
165
180
|
|
|
166
181
|
export class UpgradeRequired extends CoreError {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.6.0-
|
|
4
|
+
"version": "0.6.0-98",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -189,13 +189,30 @@ export default abstract class AuthService<
|
|
|
189
189
|
request.res.clearCookie('authorization');
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
public check(
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
public check(
|
|
193
|
+
request: TRequest,
|
|
194
|
+
role: TUserRole,
|
|
195
|
+
motivation?: string,
|
|
196
|
+
dataForDebug?: { [key: string]: any }
|
|
197
|
+
): TUser;
|
|
198
|
+
|
|
199
|
+
public check(
|
|
200
|
+
request: TRequest,
|
|
201
|
+
role: false,
|
|
202
|
+
motivation?: string,
|
|
203
|
+
dataForDebug?: { [key: string]: any }
|
|
204
|
+
): null;
|
|
205
|
+
|
|
206
|
+
public check(
|
|
207
|
+
request: TRequest,
|
|
208
|
+
role: TUserRole | false = 'USER',
|
|
209
|
+
motivation?: string,
|
|
210
|
+
dataForDebug?: { [key: string]: any }
|
|
211
|
+
): TUser | null {
|
|
195
212
|
|
|
196
213
|
const user = request.user;
|
|
197
214
|
|
|
198
|
-
this.config.debug && console.warn(LogPrefix, `Check auth, role = ${role}. Current user =`, user?.name);
|
|
215
|
+
this.config.debug && console.warn(LogPrefix, `Check auth, role = ${role}. Current user =`, user?.name, motivation);
|
|
199
216
|
|
|
200
217
|
if (user === undefined) {
|
|
201
218
|
|
|
@@ -210,7 +227,7 @@ export default abstract class AuthService<
|
|
|
210
227
|
} else if (user === null) {
|
|
211
228
|
|
|
212
229
|
this.config.debug && console.warn(LogPrefix, "Refusé pour anonyme (" + request.ip + ")");
|
|
213
|
-
throw new AuthRequired('Please login to continue');
|
|
230
|
+
throw new AuthRequired('Please login to continue', motivation, dataForDebug);
|
|
214
231
|
|
|
215
232
|
// Insufficient permissions
|
|
216
233
|
} else if (!user.roles.includes(role)) {
|
|
@@ -45,9 +45,9 @@ export default class UsersRequestService<
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// TODO: return user type according to entity
|
|
48
|
-
public check(role: TUserRole, motivation?: string): TUser;
|
|
49
|
-
public check(role: false, motivation?: string): null;
|
|
50
|
-
public check(role: TUserRole | boolean = 'USER', motivation?: string): TUser | null {
|
|
51
|
-
return this.users.check( this.request, role, motivation );
|
|
48
|
+
public check(role: TUserRole, motivation?: string, dataForDebug?: {}): TUser;
|
|
49
|
+
public check(role: false, motivation?: string, dataForDebug?: {}): null;
|
|
50
|
+
public check(role: TUserRole | boolean = 'USER', motivation?: string, dataForDebug?: {}): TUser | null {
|
|
51
|
+
return this.users.check( this.request, role, motivation, dataForDebug );
|
|
52
52
|
}
|
|
53
53
|
}
|
package/types/icons.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type TIcones = "long-arrow-right"|"times"|"
|
|
1
|
+
export type TIcones = "solid/spinner-third"|"long-arrow-right"|"times-circle"|"brands/whatsapp"|"times"|"search"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"exclamation"|"exclamation-circle"|"solid/download"|"angle-down"|"info-circle"|"check-circle"|"home"|"user-circle"|"newspaper"|"plus-circle"|"brands/linkedin"|"brands/twitter"|"brands/facebook"|"books"|"box-full"|"planet-ringed"|"chart-bar"|"power-off"|"comment-alt"|"heart"|"chart-line"|"lock"|"eye"|"credit-card"|"at"|"key"|"bars"|"font"|"tag"|"compress"|"bolt"|"puzzle-piece"|"hourglass-half"|"hourglass-end"|"rocket"|"seedling"|"palette"|"car"|"plane"|"university"|"briefcase"|"hard-hat"|"graduation-cap"|"cogs"|"film"|"leaf"|"tshirt"|"utensils"|"globe"|"map-marked-alt"|"dumbbell"|"stethoscope"|"concierge-bell"|"book"|"shield-alt"|"gavel"|"industry"|"square-root-alt"|"pills"|"medal"|"capsules"|"balance-scale"|"praying-hands"|"shopping-cart"|"flask"|"futbol"|"microchip"|"satellite-dish"|"shipping-fast"|"passport"|"tools"|"database"|"brain"|"download"|"code"|"money-bill"|"angle-left"|"angle-right"|"paper-plane"|"brands/google"|"check"|"trash"|"meh-rolling-eyes"|"arrow-left"|"arrow-right"|"link"|"file"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"unlink"|"pen"|"plus"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
|