better-auth-studio 1.0.79-beta.42 → 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,8 +5,8 @@
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-Dp09DVhf.js"></script>
9
- <link rel="stylesheet" crossorigin href="/assets/main-BgI41EAt.css">
8
+ <script type="module" crossorigin src="/assets/main-ZSnQyEBZ.js"></script>
9
+ <link rel="stylesheet" crossorigin href="/assets/main-BjWPiv1k.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="root"></div>
@@ -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,CAy2MR;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;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CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,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
@@ -1070,7 +1070,7 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
1070
1070
  router.put('/api/users/:userId', async (req, res) => {
1071
1071
  try {
1072
1072
  const { userId } = req.params;
1073
- const { name, email, role } = req.body;
1073
+ const { name, email, role, image } = req.body;
1074
1074
  const adapter = await getAuthAdapterWithConfig();
1075
1075
  if (!adapter || !adapter.update) {
1076
1076
  return res.status(500).json({ error: 'Auth adapter not available' });
@@ -1079,6 +1079,9 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
1079
1079
  if (role !== undefined) {
1080
1080
  updateData.role = role;
1081
1081
  }
1082
+ if (image !== undefined) {
1083
+ updateData.image = image;
1084
+ }
1082
1085
  const user = await adapter.update({
1083
1086
  model: 'user',
1084
1087
  where: [{ field: 'id', value: userId }],
@@ -1098,9 +1101,36 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
1098
1101
  return res.status(400).json({ error: 'Password is required' });
1099
1102
  }
1100
1103
  const adapter = await getAuthAdapterWithConfig();
1101
- if (!adapter || !adapter.update) {
1104
+ if (!adapter) {
1102
1105
  return res.status(500).json({ error: 'Auth adapter not available' });
1103
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
+ }
1104
1134
  let hashedPassword = password;
1105
1135
  try {
1106
1136
  const salt = hex.encode(crypto.getRandomValues(new Uint8Array(16)));
@@ -1108,17 +1138,18 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
1108
1138
  hashedPassword = `${salt}:${hex.encode(key)}`;
1109
1139
  }
1110
1140
  catch {
1111
- res.status(500).json({ error: 'Failed to hash password' });
1141
+ return res.status(500).json({ error: 'Failed to hash password' });
1112
1142
  }
1113
- const account = await adapter.update({
1143
+ // Update using the account's unique id to fix Prisma error
1144
+ const updatedAccount = await adapter.update({
1114
1145
  model: 'account',
1115
- where: [
1116
- { field: 'userId', value: userId },
1117
- { field: 'providerId', value: 'credential' },
1118
- ],
1119
- update: { password: hashedPassword },
1146
+ where: [{ field: 'id', value: credentialAccount.id }],
1147
+ update: {
1148
+ password: hashedPassword,
1149
+ updatedAt: new Date().toISOString(),
1150
+ },
1120
1151
  });
1121
- res.json({ success: true, account });
1152
+ res.json({ success: true, account: updatedAccount });
1122
1153
  }
1123
1154
  catch (error) {
1124
1155
  res.status(500).json({ error: 'Failed to update password', message: error?.message });