Skip to content

Commit 31352ba

Browse files
committed
feat: move buttons component under login button and add ability to set its order in array of injections
1 parent 6241f1c commit 31352ba

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

index.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface OAuthPluginOptions {
1818
enabled?: boolean;
1919
defaultFieldValues?: Record<string, any>;
2020
};
21+
componentsOrderUnderLoginButton?: number;
2122
}
2223

2324
export default class OAuthPlugin extends AdminForthPlugin {
@@ -43,9 +44,9 @@ export default class OAuthPlugin extends AdminForthPlugin {
4344
};
4445
}
4546

46-
async modifyResourceConfig(adminforth: IAdminForth, resource: AdminForthResource) {
47-
await super.modifyResourceConfig(adminforth, resource);
48-
47+
modifyResourceConfig(adminforth: IAdminForth, resource: AdminForthResource) {
48+
super.modifyResourceConfig(adminforth, resource);
49+
4950
this.adminforth = adminforth;
5051
this.resource = resource;
5152
adminforth.config.customization.customPages.push({
@@ -80,7 +81,7 @@ export default class OAuthPlugin extends AdminForthPlugin {
8081
if (!adminforth.config.customization?.loginPageInjections) {
8182
adminforth.config.customization = {
8283
...adminforth.config.customization,
83-
loginPageInjections: { underInputs: [], panelHeader: [] }
84+
loginPageInjections: { underInputs: [], underLoginButton: [], panelHeader: [] }
8485
};
8586
}
8687

@@ -99,10 +100,10 @@ export default class OAuthPlugin extends AdminForthPlugin {
99100
buttonText: `${this.options.buttonText ? this.options.buttonText : 'Continue with'} ${(adapter.getName ? adapter.getName() : adapter.constructor.name)}`,
100101
};
101102
});
102-
103-
adminforth.config.customization.loginPageInjections.underInputs.push({
103+
(adminforth.config.customization.loginPageInjections.underLoginButton as Array<any>).push({
104104
file: componentPath,
105105
meta: {
106+
afOrder: this.options.componentsOrderUnderLoginButton || 0,
106107
providers,
107108
iconOnly: this.options.iconOnly,
108109
pill: this.options.pill,
@@ -134,9 +135,7 @@ export default class OAuthPlugin extends AdminForthPlugin {
134135
username,
135136
};
136137
const toReturn = { allowedLogin: true, error: '' };
137-
138138
await this.adminforth.restApi.processLoginCallbacks(adminUser, toReturn, response, extra);
139-
140139
if (toReturn.allowedLogin) {
141140
this.adminforth.auth.setAuthCookie({
142141
response,
@@ -145,7 +144,6 @@ export default class OAuthPlugin extends AdminForthPlugin {
145144
expireInDays: this.options.authenticationExpireDuration ? this.options.authenticationExpireDuration : this.adminforth.config.auth.rememberMeDays
146145
});
147146
}
148-
149147
return toReturn;
150148
}
151149

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
]
5858
},
5959
"dependencies": {
60-
"adminforth": "^2.9.5"
60+
"adminforth": "^2.4.0-next.221"
6161
}
6262
}

types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ export interface PluginOptions {
7373
allowed: boolean;
7474
error?: string;
7575
}>;
76+
77+
/**
78+
* Order of components under the login button, if there is more than one injected component
79+
*/
80+
componentsOrderUnderLoginButton?: number;
7681
}
7782

7883
export interface HttpExtra {

0 commit comments

Comments
 (0)