5htp-core 0.3.6-7 → 0.3.6-9

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/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.3.6-7",
4
+ "version": "0.3.6-9",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -159,16 +159,20 @@ export default class ClientRouter<
159
159
  public url = (path: string, params: {} = {}, absolute: boolean = true) =>
160
160
  buildUrl(path, params, this.config.domains, absolute);
161
161
 
162
- public go( url: string ) {
162
+ public go( url: string, opt: {
163
+ newTab?: boolean
164
+ } = {}) {
163
165
 
164
166
  url = this.url(url, {}, false);
165
167
 
168
+ if (opt.newTab)
169
+ window.open(url)
166
170
  // Same domain = history url replacement
167
- if (url[0] === '/')
171
+ else if (url[0] === '/')
168
172
  history?.replace( url );
169
173
  // Different domain = hard navigation
170
174
  else
171
- windows.location.href = url;
175
+ window.location.href = url;
172
176
  }
173
177
 
174
178
  /*----------------------------------
@@ -93,7 +93,7 @@ export default abstract class UsersManagementService<
93
93
  ----------------------------------*/
94
94
 
95
95
  public abstract login( ...args: any[] ): Promise<{ user: TUser, token: string }>;
96
- public abstract decodeSession( jwt: TJwtSession, req: THttpRequest ): Promise<TUser>;
96
+ public abstract decodeSession( jwt: TJwtSession, req: THttpRequest ): Promise<TUser | null>;
97
97
 
98
98
  protected abstract displayName(user?: TUser | null): string;
99
99
  protected abstract displaySessionName(session: TJwtSession): string;
@@ -134,6 +134,11 @@ export default abstract class UsersManagementService<
134
134
  // Deserialize full user data
135
135
  this.config.debug && console.log(LogPrefix, `Deserialize user ${sessionName}`);
136
136
  const user = await this.decodeSession(session, req);
137
+
138
+ // User not found
139
+ if (user === null)
140
+ return null;
141
+
137
142
  this.config.debug && console.log(LogPrefix, `Deserialized user ${sessionName}:`, this.displayName(user));
138
143
 
139
144
  return {