Skip to content

Commit fbc8c02

Browse files
committed
feat: Enhance OAuth login button text customization and improve provider name handling
1 parent 901f0ec commit fbc8c02

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

custom/OAuthLoginButtons.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
]"
1212
>
1313
<div v-html="provider.icon" class="w-6 h-6 dark:text-white" :class="meta.iconOnly ? 'mr-0' : 'mr-4'" :alt="getProviderName(provider.provider)" />
14-
<span v-if="!meta.iconOnly" class="font-medium dark:text-white">Continue with {{ getProviderName(provider.provider) }}</span>
14+
<span v-if="!meta.iconOnly" class="font-medium dark:text-white">{{ getButtonText(provider.buttonText) }}</span>
1515
</a>
1616
</div>
1717
</template>
@@ -27,6 +27,9 @@ const props = defineProps({
2727
const getProviderName = (provider) => {
2828
return provider.replace('AdminForthAdapter', '').replace('Oauth2', '');
2929
};
30+
const getButtonText = (buttonText) => {
31+
return buttonText.replace('AdminForthAdapter', '').replace('Oauth2', '');
32+
};
3033
3134
const handleLogin = (authUrl) => {
3235
const baseUrl = props.meta.baseUrl;

index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface OAuthPluginOptions {
1010
emailField: string;
1111
emailConfirmedField?: string;
1212
adapters: OAuth2Adapter[];
13+
buttonText?: string;
1314
iconOnly?: boolean;
1415
pill?: boolean;
1516
authenticationExpireDuration?: number;
@@ -82,7 +83,7 @@ export default class OAuthPlugin extends AdminForthPlugin {
8283
loginPageInjections: { underInputs: [] }
8384
};
8485
}
85-
86+
8687
// Register the component with the correct plugin path
8788
const componentPath = `@@/plugins/${this.constructor.name}/OAuthLoginButtons.vue`;
8889
this.componentPath('OAuthLoginButtons.vue');
@@ -91,11 +92,11 @@ export default class OAuthPlugin extends AdminForthPlugin {
9192
const state = Buffer.from(JSON.stringify({
9293
provider: adapter.constructor.name
9394
})).toString('base64');
94-
9595
return {
9696
authUrl: `${adapter.getAuthUrl()}&state=${state}`,
9797
provider: adapter.constructor.name,
9898
icon: adapter.getIcon(),
99+
buttonText: `${this.options.buttonText ? this.options.buttonText : 'Continue with'} ${(adapter.getName ? adapter.getName() : adapter.constructor.name)}`,
99100
};
100101
});
101102

0 commit comments

Comments
 (0)