@adonisjs/auth 10.0.0-next.0 → 10.0.0-next.2

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.
@@ -294,16 +294,16 @@ var SessionGuard = class {
294
294
  await userProvider.deleteRemeberToken(this.user, token.identifier);
295
295
  }
296
296
  }
297
- this.user = void 0;
298
- this.viaRemember = false;
299
- this.isAuthenticated = false;
300
- this.isLoggedOut = true;
301
297
  this.#emitter.emit("session_auth:logged_out", {
302
298
  ctx: this.#ctx,
303
299
  guardName: this.#name,
304
300
  user: this.user || null,
305
301
  sessionId: session.sessionId
306
302
  });
303
+ this.user = void 0;
304
+ this.viaRemember = false;
305
+ this.isAuthenticated = false;
306
+ this.isLoggedOut = true;
307
307
  }
308
308
  /**
309
309
  * Authenticate the current HTTP request by verifying the bearer
@@ -1,4 +1,4 @@
1
- import type { Hash } from '@adonisjs/core/hash';
1
+ import type { Hash, HashManager } from '@adonisjs/core/hash';
2
2
  import { type BaseModel } from '@adonisjs/lucid/orm';
3
3
  import type { NormalizeConstructor } from '@adonisjs/core/types/helpers';
4
4
  type UserWithUserFinderRow = {
@@ -34,8 +34,8 @@ type UserWithUserFinderClass<Model extends NormalizeConstructor<typeof BaseModel
34
34
  * // User model implementation
35
35
  * }
36
36
  */
37
- export declare function withAuthFinder(hash: () => Hash, options: {
38
- uids: string[];
39
- passwordColumnName: string;
37
+ export declare function withAuthFinder(hash: (() => Hash) | HashManager<any>, options?: {
38
+ uids?: string[];
39
+ passwordColumnName?: string;
40
40
  }): <Model extends NormalizeConstructor<typeof BaseModel>>(superclass: Model) => UserWithUserFinderClass<Model>;
41
41
  export {};
@@ -9,13 +9,15 @@ import {
9
9
  import { RuntimeException } from "@adonisjs/core/exceptions";
10
10
  import { beforeSave } from "@adonisjs/lucid/orm";
11
11
  function withAuthFinder(hash, options) {
12
+ let normalizedOptions = { uids: ["email"], passwordColumnName: "password", ...options };
13
+ let hashFactory = typeof hash === "function" ? hash : () => hash.use();
12
14
  return function(superclass) {
13
15
  class UserWithUserFinder extends superclass {
14
16
  static async hashPassword(user) {
15
- if (user.$dirty[options.passwordColumnName]) {
17
+ if (user.$dirty[normalizedOptions.passwordColumnName]) {
16
18
  ;
17
- user[options.passwordColumnName] = await hash().make(
18
- user[options.passwordColumnName]
19
+ user[normalizedOptions.passwordColumnName] = await hashFactory().make(
20
+ user[normalizedOptions.passwordColumnName]
19
21
  );
20
22
  }
21
23
  }
@@ -52,9 +54,9 @@ function withAuthFinder(hash, options) {
52
54
  if (!uid || !password) {
53
55
  throw new E_INVALID_CREDENTIALS("Invalid user credentials");
54
56
  }
55
- const user = await this.findForAuth(options.uids, uid);
57
+ const user = await this.findForAuth(normalizedOptions.uids, uid);
56
58
  if (!user) {
57
- await hash().make(password);
59
+ await hashFactory().make(password);
58
60
  throw new E_INVALID_CREDENTIALS("Invalid user credentials");
59
61
  }
60
62
  if (await user.verifyPassword(password)) {
@@ -77,13 +79,13 @@ function withAuthFinder(hash, options) {
77
79
  * }
78
80
  */
79
81
  verifyPassword(plainPassword) {
80
- const passwordHash = this[options.passwordColumnName];
82
+ const passwordHash = this[normalizedOptions.passwordColumnName];
81
83
  if (!passwordHash) {
82
84
  throw new RuntimeException(
83
- `Cannot verify password. The value for "${options.passwordColumnName}" column is undefined or null`
85
+ `Cannot verify password. The value for "${normalizedOptions.passwordColumnName}" column is undefined or null`
84
86
  );
85
87
  }
86
- return hash().verify(passwordHash, plainPassword);
88
+ return hashFactory().verify(passwordHash, plainPassword);
87
89
  }
88
90
  }
89
91
  __decorateClass([
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/auth",
3
3
  "description": "Official authentication provider for Adonis framework",
4
- "version": "10.0.0-next.0",
4
+ "version": "10.0.0-next.2",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -51,11 +51,11 @@
51
51
  "quick:test": "cross-env NODE_DEBUG=\"adonisjs:auth:*\" node --enable-source-maps --import=@poppinss/ts-exec ./bin/test.js"
52
52
  },
53
53
  "devDependencies": {
54
- "@adonisjs/assembler": "^8.0.0-next.9",
55
- "@adonisjs/core": "^7.0.0-next.1",
54
+ "@adonisjs/assembler": "^8.0.0-next.14",
55
+ "@adonisjs/core": "^7.0.0-next.8",
56
56
  "@adonisjs/eslint-config": "^3.0.0-next.1",
57
- "@adonisjs/i18n": "^3.0.0-next.0",
58
- "@adonisjs/lucid": "^22.0.0-next.0",
57
+ "@adonisjs/i18n": "^3.0.0-next.1",
58
+ "@adonisjs/lucid": "^22.0.0-next.1",
59
59
  "@adonisjs/prettier-config": "^1.4.5",
60
60
  "@adonisjs/session": "^8.0.0-next.0",
61
61
  "@adonisjs/tsconfig": "^2.0.0-next.0",
@@ -71,21 +71,21 @@
71
71
  "@release-it/conventional-changelog": "^10.0.1",
72
72
  "@types/basic-auth": "^1.1.8",
73
73
  "@types/luxon": "^3.7.1",
74
- "@types/node": "^24.5.2",
74
+ "@types/node": "^24.9.1",
75
75
  "@types/set-cookie-parser": "^2.4.10",
76
76
  "@types/sinon": "^17.0.4",
77
77
  "c8": "^10.1.3",
78
78
  "convert-hrtime": "^5.0.0",
79
79
  "copyfiles": "^2.4.1",
80
- "cross-env": "^10.0.0",
80
+ "cross-env": "^10.1.0",
81
81
  "del-cli": "^7.0.0",
82
- "dotenv": "^17.2.2",
83
- "eslint": "^9.36.0",
82
+ "dotenv": "^17.2.3",
83
+ "eslint": "^9.38.0",
84
84
  "luxon": "^3.7.2",
85
- "mysql2": "^3.15.0",
85
+ "mysql2": "^3.15.3",
86
86
  "nock": "^14.0.10",
87
87
  "pg": "^8.16.3",
88
- "playwright": "^1.55.0",
88
+ "playwright": "^1.56.1",
89
89
  "prettier": "^3.6.2",
90
90
  "release-it": "^19.0.5",
91
91
  "set-cookie-parser": "^2.7.1",
@@ -94,7 +94,7 @@
94
94
  "tedious": "^18.6.1",
95
95
  "timekeeper": "^2.3.1",
96
96
  "tsup": "^8.5.0",
97
- "typescript": "^5.9.2"
97
+ "typescript": "^5.9.3"
98
98
  },
99
99
  "dependencies": {
100
100
  "@adonisjs/presets": "^3.0.0-next.0",
@@ -103,6 +103,7 @@
103
103
  "peerDependencies": {
104
104
  "@adonisjs/assembler": "^8.0.0-next.9",
105
105
  "@adonisjs/core": "^7.0.0-next.1",
106
+ "@adonisjs/i18n": "^3.0.0-next.0",
106
107
  "@adonisjs/lucid": "^22.0.0-next.0",
107
108
  "@adonisjs/session": "^8.0.0-next.0",
108
109
  "@japa/api-client": "^3.1.0",
@@ -113,6 +114,9 @@
113
114
  "@adonisjs/assembler": {
114
115
  "optional": true
115
116
  },
117
+ "@adonisjs/i18n": {
118
+ "optional": true
119
+ },
116
120
  "@adonisjs/lucid": {
117
121
  "optional": true
118
122
  },