better-auth-studio 1.0.79-beta.43 → 1.0.79-beta.45
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/{public/assets/main-DqJQa2nz.js → dist/public/assets/main-ZSnQyEBZ.js} +42 -42
- package/dist/public/index.html +1 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +36 -9
- package/dist/routes.js.map +1 -1
- package/dist/studio.d.ts.map +1 -1
- package/dist/studio.js +13 -0
- package/dist/studio.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/main-ZSnQyEBZ.js +1155 -0
- package/public/index.html +1 -1
package/dist/public/index.html
CHANGED
|
@@ -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-
|
|
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>
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -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,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C;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
|
|
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,17 @@ 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
|
|
1143
|
+
const updatedAccount = await adapter.update({
|
|
1117
1144
|
model: 'account',
|
|
1118
|
-
where: [
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1145
|
+
where: [{ field: 'id', value: credentialAccount.id }],
|
|
1146
|
+
update: {
|
|
1147
|
+
password: hashedPassword,
|
|
1148
|
+
updatedAt: new Date().toISOString(),
|
|
1149
|
+
},
|
|
1123
1150
|
});
|
|
1124
|
-
res.json({ success: true, account });
|
|
1151
|
+
res.json({ success: true, account: updatedAccount });
|
|
1125
1152
|
}
|
|
1126
1153
|
catch (error) {
|
|
1127
1154
|
res.status(500).json({ error: 'Failed to update password', message: error?.message });
|