PHP code example of edrisaturay / filament-azure-socialite
1. Go to this page and download the library: Download edrisaturay/filament-azure-socialite library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
edrisaturay / filament-azure-socialite example snippets
use EdrisaTuray\FilamentAzureSocialite\FilamentAzureSocialitePlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
FilamentAzureSocialitePlugin::make()
->enabled()
->buttonLabel('Login with Microsoft')
->hook('after') // or 'before'
->allowRegistration(true)
->allowedDomains(['company.com']) // Optional
->allowedTenants(['tenant-id']) // Optional
]);
}
use EdrisaTuray\FilamentAzureSocialite\FilamentAzureSocialitePlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
FilamentAzureSocialitePlugin::make()
->enabled()
->buttonLabel('Login with Microsoft')
->hook('after')
->allowRegistration(true)
]);
}
FilamentAzureSocialitePlugin::make()
->enabled(true) // Enable/disable the plugin
->buttonLabel('Login with Microsoft') // Button text
->hook('after') // 'before' or 'after' the login form
->allowRegistration(true) // Allow creating new users
FilamentAzureSocialitePlugin::make()
->allowedDomains(['company.com', 'partner.com']) // Restrict to specific email domains
->allowedTenants(['tenant-id-1', 'tenant-id-2']) // Restrict to specific Azure tenants
FilamentAzureSocialitePlugin::make()
->resolveUserUsing(function ($azureUser) {
// Custom logic to find or create user
return User::firstOrCreate(
['email' => $azureUser->getEmail()],
[
'name' => $azureUser->getName(),
'role' => 'user',
]
);
})
FilamentAzureSocialitePlugin::make()
->beforeRedirect(function ($request, $config) {
// Called before redirecting to Azure
// You can modify $config here
})
->afterUserResolved(function ($user, $azureUser) {
// Called after user is resolved/created
// Useful for syncing additional data
})