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.
@@ -12,4 +12,4 @@
12
12
  .bl-2, .bh-2 { border-left: solid 1px var(--cLine); }
13
13
 
14
14
  .b-0 { border: none; }
15
- .b-1 { border-top: solid 1px var(--cLine); }
15
+ .b-1 { border: solid 1px var(--cLine); }
@@ -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-96",
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( request: TRequest, role: TUserRole): TUser;
193
- public check( request: TRequest, role: false): null;
194
- public check( request: TRequest, role: TUserRole | false = 'USER'): TUser | null {
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"|"solid/spinner-third"|"check-circle"|"coins"|"building"|"at"|"phone"|"bolt"|"brands/linkedin"|"rocket"|"chart-bar"|"user-circle"|"plane-departure"|"plus-circle"|"comments-alt"|"arrow-right"|"crosshairs"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"calendar-alt"|"paper-plane"|"user-plus"|"magnet"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"user"|"sun"|"brands/whatsapp"|"search"|"lightbulb"|"angle-up"|"angle-down"|"solid/crown"|"eye"|"pen"|"plus"|"file"|"envelope"|"clock"|"cog"|"trash"|"ellipsis-h"|"check"|"pencil"|"regular/shield-check"|"binoculars"|"download"|"exclamation-circle"|"times-circle"|"arrow-left"|"meh-rolling-eyes"|"bars"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"power-off"|"external-link"|"question-circle"|"play"|"minus-circle"|"wind"|"users"|"bug"|"map-marker-alt"|"arrow-to-bottom"|"broom"|"brands/google"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"exclamation-triangle"|"minus"|"plug"|"comment-alt"|"coin"|"briefcase"|"map-marker"|"fire"|"solid/magic"|"industry"|"calendar"|"globe"|"magic"|"graduation-cap"|"code"|"bold"|"italic"|"underline"|"font"|"strikethrough"|"subscript"|"superscript"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"unlink"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
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"