better-auth-studio 1.0.79-beta.43 → 1.0.79-beta.44

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.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/png" href="/logo.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Better Auth Studio</title>
8
- <script type="module" crossorigin src="/assets/main-DqJQa2nz.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-ZSnQyEBZ.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/main-BjWPiv1k.css">
10
10
  </head>
11
11
  <body>
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAU9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA0GnE,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAqLhG;AAeD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,gBAAgB,CAAC,EAAE,GAAG,EACtB,oBAAoB,CAAC,EAAE,GAAG,EAC1B,YAAY,CAAC,EAAE,kBAAkB,EACjC,YAAY,CAAC,EAAE,GAAG,GACjB,MAAM,CA42MR;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,GAAG,CAAC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E,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CAChE,CAAC,CA+FD"}
package/dist/routes.js CHANGED
@@ -1101,9 +1101,36 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
1101
1101
  return res.status(400).json({ error: 'Password is required' });
1102
1102
  }
1103
1103
  const adapter = await getAuthAdapterWithConfig();
1104
- if (!adapter || !adapter.update) {
1104
+ if (!adapter) {
1105
1105
  return res.status(500).json({ error: 'Auth adapter not available' });
1106
1106
  }
1107
+ if (!adapter.update) {
1108
+ return res.status(500).json({ error: 'Auth adapter update method not available' });
1109
+ }
1110
+ // Find the credential account first to get its unique id
1111
+ let credentialAccount = null;
1112
+ if (adapter.findFirst) {
1113
+ credentialAccount = await adapter.findFirst({
1114
+ model: 'account',
1115
+ where: [
1116
+ { field: 'userId', value: userId },
1117
+ { field: 'providerId', value: 'credential' },
1118
+ ],
1119
+ });
1120
+ }
1121
+ else if (adapter.findMany) {
1122
+ const accounts = await adapter.findMany({
1123
+ model: 'account',
1124
+ where: [
1125
+ { field: 'userId', value: userId },
1126
+ { field: 'providerId', value: 'credential' },
1127
+ ],
1128
+ });
1129
+ credentialAccount = accounts && accounts.length > 0 ? accounts[0] : null;
1130
+ }
1131
+ if (!credentialAccount) {
1132
+ return res.status(404).json({ error: 'Credential account not found for this user' });
1133
+ }
1107
1134
  let hashedPassword = password;
1108
1135
  try {
1109
1136
  const salt = hex.encode(crypto.getRandomValues(new Uint8Array(16)));
@@ -1111,17 +1138,18 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
1111
1138
  hashedPassword = `${salt}:${hex.encode(key)}`;
1112
1139
  }
1113
1140
  catch {
1114
- res.status(500).json({ error: 'Failed to hash password' });
1141
+ return res.status(500).json({ error: 'Failed to hash password' });
1115
1142
  }
1116
- const account = await adapter.update({
1143
+ // Update using the account's unique id to fix Prisma error
1144
+ const updatedAccount = await adapter.update({
1117
1145
  model: 'account',
1118
- where: [
1119
- { field: 'userId', value: userId },
1120
- { field: 'providerId', value: 'credential' },
1121
- ],
1122
- update: { password: hashedPassword },
1146
+ where: [{ field: 'id', value: credentialAccount.id }],
1147
+ update: {
1148
+ password: hashedPassword,
1149
+ updatedAt: new Date().toISOString(),
1150
+ },
1123
1151
  });
1124
- res.json({ success: true, account });
1152
+ res.json({ success: true, account: updatedAccount });
1125
1153
  }
1126
1154
  catch (error) {
1127
1155
  res.status(500).json({ error: 'Failed to update password', message: error?.message });