better-auth-university 0.2.0 → 0.3.0
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/README.md +3 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +14 -7
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -10,7 +10,9 @@ npm install better-auth-university
|
|
|
10
10
|
|
|
11
11
|
## Setup
|
|
12
12
|
|
|
13
|
-
To use the Better Auth University Plugin, you need to configure it with a list of universities and their associated email domains. You can also specify allowed email domains for user registration.
|
|
13
|
+
To use the Better Auth University Plugin, you need to configure it with a list of universities and their associated email domains. You can also specify allowed email domains for user registration.
|
|
14
|
+
|
|
15
|
+
If you would like a comprehensive list of universities, consider going to the [university-domains-list](https://github.com/Hipo/university-domains-list) for options of obtaining the data. There is a world_universities_and_domains.json which can be easily passed to the `university` parameter.
|
|
14
16
|
|
|
15
17
|
```typescript
|
|
16
18
|
import { universityResolver } from "better-auth-university";
|
package/dist/index.d.ts
CHANGED
|
@@ -23,5 +23,12 @@ export interface UniversityResolverOptions {
|
|
|
23
23
|
* Pass `['*']` to allow all domains.
|
|
24
24
|
*/
|
|
25
25
|
allowedEmailDomains?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Whether to create a university entry if the email domain is not found
|
|
28
|
+
* in the provided list.
|
|
29
|
+
*
|
|
30
|
+
* Defaults to `false`.
|
|
31
|
+
*/
|
|
32
|
+
createIfNotFound?: boolean;
|
|
26
33
|
}
|
|
27
34
|
export declare const universityResolver: (options: UniversityResolverOptions) => BetterAuthPlugin;
|
package/dist/index.js
CHANGED
|
@@ -49,13 +49,20 @@ export const universityResolver = (options) => {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
if (options.createIfNotFound) {
|
|
53
|
+
university = await adapter.create({
|
|
54
|
+
model: "university",
|
|
55
|
+
data: {
|
|
56
|
+
name: emailDomain,
|
|
57
|
+
domain: emailDomain,
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw new APIError("BAD_REQUEST", {
|
|
63
|
+
message: "University not found for the provided email domain."
|
|
64
|
+
});
|
|
65
|
+
}
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
68
|
if (university) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth-university",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A university plugin for Better Auth that allows restriction of email domains.",
|
|
5
5
|
"author": "Jaren Goldberg <fyrlex@gmail.com>",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"require": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./client": {
|
|
20
|
+
"import": "./dist/client.js",
|
|
21
|
+
"types": "./dist/client.d.ts",
|
|
22
|
+
"require": "./dist/client.js"
|
|
18
23
|
}
|
|
19
24
|
},
|
|
20
25
|
"scripts": {
|
|
@@ -37,7 +42,7 @@
|
|
|
37
42
|
},
|
|
38
43
|
"homepage": "https://github.com/LuyxLLC/better-auth-university#readme",
|
|
39
44
|
"peerDependencies": {
|
|
40
|
-
"better-auth": "^1.4.
|
|
45
|
+
"better-auth": "^1.4.6"
|
|
41
46
|
},
|
|
42
47
|
"devDependencies": {
|
|
43
48
|
"typescript": "^5.9.3"
|