Implement Google authentication (for Web) and user management system

This commit is contained in:
Michał Zieliński
2025-07-19 22:50:38 +02:00
parent b673fd2da3
commit 14c61ca1ee
25 changed files with 1072 additions and 41 deletions

View File

@@ -0,0 +1,35 @@
window.initGoogleSignIn = async function(clientId) {
try {
if (!clientId) {
throw new Error('ClientId is required');
}
// Inicjalizacja Google Sign-In z dynamicznym ClientId
google.accounts.id.initialize({
client_id: clientId,
callback: handleGoogleResponse,
auto_select: false,
cancel_on_tap_outside: true
});
// Wyświetl popup logowania
google.accounts.id.prompt((notification) => {
if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
console.log('Google Sign-In popup not displayed');
}
});
} catch (error) {
console.error('Google Sign-In initialization error:', error);
DotNet.invokeMethodAsync('Bimix.UI.Shared', 'OnGoogleSignInError', error.message);
}
};
function handleGoogleResponse(response) {
if (response.credential) {
// Token otrzymany - wyślij do Blazor
DotNet.invokeMethodAsync('Bimix.UI.Shared', 'OnGoogleSignInSuccess', response.credential);
} else {
DotNet.invokeMethodAsync('Bimix.UI.Shared', 'OnGoogleSignInError', 'No credential received');
}
}