Skip to content

Commit 9c5d0c1

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents 98cd416 + 62300fb commit 9c5d0c1

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Why AdminForth:
2727
* Define express APIs and call them from your components and pages
2828
* Use various modern back-office-must-have plugins like audit log, files/image upload, TOTP 2FA, I18N, Copilot-style AI writing and image generation
2929

30+
3031
## Project initialisation
3132

3233
```
@@ -56,27 +57,35 @@ npx adminforth create-app
5657

5758
# For developers
5859

59-
```
60+
The most convenient way to add new features or fixes is using `dev-demo`. It imports the source code of the repository and plugins so you can edit them and see changes on the fly.
61+
62+
Fork repo, pull it and do next:
63+
64+
65+
```sh
6066
cd adminforth
6167
npm ci
6268
npm run build
6369

64-
6570
# this will install all official plugins and link adminforth package, if plugin installed it will git pull and npm ci
6671
npm run install-plugins
6772

6873
# same for official adapters
6974
npm run install-adapters
75+
```
7076

71-
# this is dev demo for development
77+
To run dev demo:
78+
```sh
7279
cd dev-demo
7380
cp .env.sample .env
7481
npm ci
7582
npm run migrate
7683
npm start
7784
```
7885

79-
Add some columns to a database. Open .prisma file, modify it, and run:
86+
## Adding columns to a database in dev-demo
87+
88+
Open `.prisma` file, modify it, and run:
8089

8190
```
8291
npm run namemigration -- --name desctiption_of_changes

adminforth/documentation/docs/tutorial/05-Plugins/11-oauth.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ plugins: [
5757
new AdminForthAdapterGoogleOauth2({
5858
clientID: process.env.GOOGLE_OAUTH_CLIENT_ID,
5959
clientSecret: process.env.GOOGLE_OAUTH_CLIENT_SECRET,
60-
redirectUri: 'http://localhost:3000/oauth/callback',
6160
}),
6261
],
6362

@@ -88,7 +87,7 @@ npx prisma migrate dev --name add-email-confirmed-to-adminuser
8887
3. Configure the plugin with `emailConfirmedField`:
8988

9089
```typescript title="./resources/adminuser.ts"
91-
new OAuth2Plugin({
90+
new OAuthPlugin({
9291
// ... adapters configuration ...
9392
emailField: 'email',
9493
emailConfirmedField: 'email_confirmed' // Enable email confirmation tracking
@@ -99,3 +98,35 @@ When using OAuth:
9998
- New users will have their email automatically confirmed (`email_confirmed = true`)
10099
- Existing users will have their email marked as confirmed upon successful OAuth login
101100
- The `email_confirmed` field must be a boolean type
101+
102+
### 4. Open Signup
103+
104+
By default, users must exist in the system before they can log in with OAuth. You can enable automatic user creation for new OAuth users with the `openSignup` option:
105+
106+
```typescript title="./resources/adminuser.ts"
107+
new OAuthPlugin({
108+
// ... adapters configuration ...
109+
openSignup: {
110+
enabled: true,
111+
defaultFieldValues: { // Set default values for new users
112+
role: 'user',
113+
},
114+
},
115+
}),
116+
```
117+
118+
### 5. UI Customization
119+
120+
You can customize the UI of the OAuth login buttons by using the `iconOnly` and `pill` options.
121+
122+
```typescript title="./resources/adminuser.ts"
123+
new OAuthPlugin({
124+
// ... adapters configuration ...
125+
iconOnly: true, // Show only provider icons without text
126+
pill: true, // Use pill-shaped buttons instead of rectangular
127+
}),
128+
```
129+
130+
131+
132+

adminforth/types/Adapters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export interface CompletionAdapter {
2727

2828
export interface OAuth2Adapter {
2929
getAuthUrl(): string;
30-
getTokenFromCode(code: string): Promise<{ email: string }>;
30+
getTokenFromCode(code: string, redirect_uri: string): Promise<{ email: string }>;
3131
getIcon(): string;
3232
}

dev-demo/resources/users.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import TwoFactorsAuthPlugin from "../../plugins/adminforth-two-factors-auth";
1111
import EmailResetPasswordPlugin from "../../plugins/adminforth-email-password-reset/index.js";
1212
import { v1 as uuid } from "uuid";
1313
import EmailAdapterAwsSes from "../../adapters/adminforth-email-adapter-aws-ses/index.js";
14-
import OAuthPlugin from "../../plugins/adminforth-oauth";
14+
15+
import OAuthPlugin from "../../plugins/adminforth-oauth";
1516
import AdminForthAdapterGoogleOauth2 from "../../adapters/adminforth-google-oauth-adapter";
16-
import AdminForthAdapterGithubOauth2 from "../../adapters/adminforth-github-oauth-adapter";
17+
import AdminForthAdapterGithubOauth2 from "../../adapters/adminforth-github-oauth-adapter";
18+
1719
export default {
1820
dataSource: "maindb",
1921
table: "users",

0 commit comments

Comments
 (0)