better-auth-studio 1.0.79-beta.36 → 1.0.79-beta.37
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/dist/cli.js +0 -0
- package/dist/public/assets/{main-BxLtFscV.js → main-DEnyGsn2.js} +1 -1
- package/dist/public/index.html +1 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +108 -23
- package/dist/routes.js.map +1 -1
- package/package.json +29 -30
- package/public/assets/{main-BxLtFscV.js → main-DEnyGsn2.js} +1 -1
- 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-DEnyGsn2.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/main-BgI41EAt.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,EAAE,MAAM,EAClB,gBAAgB,CAAC,EAAE,GAAG,EAC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AAE,GAAG,CAAA;KAAE,CAAC,CAAC;CAChE,CAAC,CA+FD"}
|
package/dist/routes.js
CHANGED
|
@@ -2721,6 +2721,26 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2721
2721
|
if (!adapter.update) {
|
|
2722
2722
|
return res.status(500).json({ error: 'Adapter update method not available' });
|
|
2723
2723
|
}
|
|
2724
|
+
let invitation = null;
|
|
2725
|
+
try {
|
|
2726
|
+
invitation = await adapter.findOne({
|
|
2727
|
+
model: 'invitation',
|
|
2728
|
+
where: [{ field: 'id', value: id }],
|
|
2729
|
+
});
|
|
2730
|
+
}
|
|
2731
|
+
catch (_findError) {
|
|
2732
|
+
if (typeof adapter.findMany === 'function') {
|
|
2733
|
+
const invitations = await adapter.findMany({
|
|
2734
|
+
model: 'invitation',
|
|
2735
|
+
where: [{ field: 'id', value: id }],
|
|
2736
|
+
limit: 1,
|
|
2737
|
+
});
|
|
2738
|
+
invitation = invitations && invitations.length > 0 ? invitations[0] : null;
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
if (!invitation) {
|
|
2742
|
+
return res.status(404).json({ error: 'Invitation not found' });
|
|
2743
|
+
}
|
|
2724
2744
|
await adapter.update({
|
|
2725
2745
|
model: 'invitation',
|
|
2726
2746
|
where: [{ field: 'id', value: id }],
|
|
@@ -2731,8 +2751,13 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2731
2751
|
});
|
|
2732
2752
|
res.json({ success: true });
|
|
2733
2753
|
}
|
|
2734
|
-
catch (
|
|
2735
|
-
|
|
2754
|
+
catch (error) {
|
|
2755
|
+
console.error('Error resending invitation:', error);
|
|
2756
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to resend invitation';
|
|
2757
|
+
res.status(500).json({
|
|
2758
|
+
error: 'Failed to resend invitation',
|
|
2759
|
+
details: isSelfHosted ? errorMessage : undefined,
|
|
2760
|
+
});
|
|
2736
2761
|
}
|
|
2737
2762
|
});
|
|
2738
2763
|
router.get('/api/users/:userId/invitations', async (req, res) => {
|
|
@@ -2994,7 +3019,13 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2994
3019
|
router.post('/api/organizations/:orgId/invitations', async (req, res) => {
|
|
2995
3020
|
try {
|
|
2996
3021
|
const { orgId } = req.params;
|
|
2997
|
-
const { email, role = 'member', inviterId } = req.body;
|
|
3022
|
+
const { email, role = 'member', inviterId, teamId } = req.body;
|
|
3023
|
+
if (!email || typeof email !== 'string') {
|
|
3024
|
+
return res.status(400).json({ error: 'Email is required' });
|
|
3025
|
+
}
|
|
3026
|
+
if (!orgId) {
|
|
3027
|
+
return res.status(400).json({ error: 'Organization ID is required' });
|
|
3028
|
+
}
|
|
2998
3029
|
if (!inviterId) {
|
|
2999
3030
|
return res.status(400).json({ error: 'Inviter ID is required' });
|
|
3000
3031
|
}
|
|
@@ -3002,8 +3033,66 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
3002
3033
|
if (!adapter) {
|
|
3003
3034
|
return res.status(500).json({ error: 'Auth adapter not available' });
|
|
3004
3035
|
}
|
|
3036
|
+
if (!adapter.create) {
|
|
3037
|
+
return res.status(500).json({ error: 'Adapter create method not available' });
|
|
3038
|
+
}
|
|
3039
|
+
try {
|
|
3040
|
+
const organization = await adapter.findOne({
|
|
3041
|
+
model: 'organization',
|
|
3042
|
+
where: [{ field: 'id', value: orgId }],
|
|
3043
|
+
});
|
|
3044
|
+
if (!organization) {
|
|
3045
|
+
return res.status(404).json({ error: 'Organization not found' });
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
catch (orgError) {
|
|
3049
|
+
try {
|
|
3050
|
+
if (typeof adapter.findMany === 'function') {
|
|
3051
|
+
const orgs = await adapter.findMany({
|
|
3052
|
+
model: 'organization',
|
|
3053
|
+
where: [{ field: 'id', value: orgId }],
|
|
3054
|
+
limit: 1,
|
|
3055
|
+
});
|
|
3056
|
+
if (!orgs || orgs.length === 0) {
|
|
3057
|
+
return res.status(404).json({ error: 'Organization not found' });
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
catch (_fallbackError) { }
|
|
3062
|
+
}
|
|
3063
|
+
try {
|
|
3064
|
+
let existingInvitation = null;
|
|
3065
|
+
if (typeof adapter.findFirst === 'function') {
|
|
3066
|
+
existingInvitation = await adapter.findFirst({
|
|
3067
|
+
model: 'invitation',
|
|
3068
|
+
where: [
|
|
3069
|
+
{ field: 'email', value: email.toLowerCase() },
|
|
3070
|
+
{ field: 'organizationId', value: orgId },
|
|
3071
|
+
{ field: 'status', value: 'pending' },
|
|
3072
|
+
],
|
|
3073
|
+
});
|
|
3074
|
+
}
|
|
3075
|
+
else if (typeof adapter.findMany === 'function') {
|
|
3076
|
+
const invitations = await adapter.findMany({
|
|
3077
|
+
model: 'invitation',
|
|
3078
|
+
where: [
|
|
3079
|
+
{ field: 'email', value: email.toLowerCase() },
|
|
3080
|
+
{ field: 'organizationId', value: orgId },
|
|
3081
|
+
{ field: 'status', value: 'pending' },
|
|
3082
|
+
],
|
|
3083
|
+
limit: 1,
|
|
3084
|
+
});
|
|
3085
|
+
existingInvitation = invitations && invitations.length > 0 ? invitations[0] : null;
|
|
3086
|
+
}
|
|
3087
|
+
if (existingInvitation) {
|
|
3088
|
+
return res
|
|
3089
|
+
.status(400)
|
|
3090
|
+
.json({ error: 'A pending invitation already exists for this email' });
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
catch (_duplicateCheckError) { }
|
|
3005
3094
|
const invitationData = {
|
|
3006
|
-
email,
|
|
3095
|
+
email: email.toLowerCase(),
|
|
3007
3096
|
role,
|
|
3008
3097
|
organizationId: orgId,
|
|
3009
3098
|
status: 'pending',
|
|
@@ -3011,29 +3100,25 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
3011
3100
|
createdAt: new Date(),
|
|
3012
3101
|
inviterId: inviterId,
|
|
3013
3102
|
};
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
...invitationData,
|
|
3017
|
-
};
|
|
3018
|
-
if (!adapter.create) {
|
|
3019
|
-
return res.status(500).json({ error: 'Adapter create method not available' });
|
|
3103
|
+
if (teamId) {
|
|
3104
|
+
invitationData.teamId = teamId;
|
|
3020
3105
|
}
|
|
3021
|
-
await adapter.create({
|
|
3106
|
+
const createdInvitation = await adapter.create({
|
|
3022
3107
|
model: 'invitation',
|
|
3023
|
-
data:
|
|
3024
|
-
organizationId: invitationData.organizationId,
|
|
3025
|
-
email: invitationData.email,
|
|
3026
|
-
role: invitationData.role,
|
|
3027
|
-
status: invitationData.status,
|
|
3028
|
-
inviterId: invitationData.inviterId,
|
|
3029
|
-
expiresAt: invitationData.expiresAt,
|
|
3030
|
-
createdAt: invitationData.createdAt,
|
|
3031
|
-
},
|
|
3108
|
+
data: invitationData,
|
|
3032
3109
|
});
|
|
3033
|
-
|
|
3110
|
+
if (!createdInvitation) {
|
|
3111
|
+
return res.status(500).json({ error: 'Failed to create invitation' });
|
|
3112
|
+
}
|
|
3113
|
+
res.json({ success: true, invitation: createdInvitation });
|
|
3034
3114
|
}
|
|
3035
|
-
catch (
|
|
3036
|
-
|
|
3115
|
+
catch (error) {
|
|
3116
|
+
console.error('Error creating invitation:', error);
|
|
3117
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to create invitation';
|
|
3118
|
+
res.status(500).json({
|
|
3119
|
+
error: 'Failed to create invitation',
|
|
3120
|
+
details: isSelfHosted ? errorMessage : undefined,
|
|
3121
|
+
});
|
|
3037
3122
|
}
|
|
3038
3123
|
});
|
|
3039
3124
|
router.get('/api/organizations/:orgId/teams', async (req, res) => {
|