OAuthCallback
TsgcHTMLComponent_OAuthCallback — renderuje stronę docelową OAuth w stanie sukcesu, błędu lub ładowania, pokazując zalogowanego użytkownika i automatyczne przekierowanie, w Delphi, C++ Builder i .NET.
TsgcHTMLComponent_OAuthCallback — renderuje stronę docelową OAuth w stanie sukcesu, błędu lub ładowania, pokazując zalogowanego użytkownika i automatyczne przekierowanie, w Delphi, C++ Builder i .NET.
Strona, którą udostępniasz spod swojego identyfikatora URI przekierowania OAuth. Ustaw Status i dane użytkownika, a następnie odczytaj HTML — albo użyj statycznych metod pomocniczych BuildSuccess, BuildError i BuildLoading dla jednolinijkowca.
TsgcHTMLComponent_OAuthCallback
Strona zwrotna Bootstrap 5
Delphi, C++ Builder, .NET
Statyczne metody pomocnicze Build* renderują gotową stronę bezpośrednio. Użyj pełnego komponentu, gdy potrzebujesz ustawić awatar, metodę przekierowania lub niestandardowe ikony.
uses
sgcHTML_Enums, sgcHTML_Component_OAuthCallback;
// Success page (with auto-redirect to /dashboard):
WebModule.Response := TsgcHTMLComponent_OAuthCallback.BuildSuccess(
'Google', 'Jane Doe', '/dashboard', 'jane@acme.com');
// Error page:
WebModule.Response := TsgcHTMLComponent_OAuthCallback.BuildError(
'Google', 'access_denied');
// Loading / interstitial page:
WebModule.Response := TsgcHTMLComponent_OAuthCallback.BuildLoading('Google');
// Full control:
var
oCB: TsgcHTMLComponent_OAuthCallback;
begin
oCB := TsgcHTMLComponent_OAuthCallback.Create(nil);
try
oCB.Status := csSuccess;
oCB.ProviderName := 'Google';
oCB.UserName := 'Jane Doe';
oCB.UserAvatar := 'https://acme.com/u/jane.png';
oCB.RedirectURL := '/dashboard';
oCB.RedirectMethod := rmAutoRedirect;
oCB.RedirectDelay := 3;
WebModule.Response := oCB.HTML;
finally
oCB.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_OAuthCallback.hpp
// Success page (with auto-redirect to /dashboard):
String ok = TsgcHTMLComponent_OAuthCallback::BuildSuccess(
"Google", "Jane Doe", "/dashboard", "jane@acme.com");
// Error page:
String err = TsgcHTMLComponent_OAuthCallback::BuildError(
"Google", "access_denied");
// Loading / interstitial page:
String wait = TsgcHTMLComponent_OAuthCallback::BuildLoading("Google");
// Full control:
TsgcHTMLComponent_OAuthCallback *oCB = new TsgcHTMLComponent_OAuthCallback(NULL);
try
{
oCB->Status = csSuccess;
oCB->ProviderName = "Google";
oCB->UserName = "Jane Doe";
oCB->UserAvatar = "https://acme.com/u/jane.png";
oCB->RedirectURL = "/dashboard";
oCB->RedirectMethod = rmAutoRedirect;
oCB->RedirectDelay = 3;
String html = oCB->HTML;
}
__finally
{
delete oCB;
}
using esegece.sgcWebSockets;
// Success page (with auto-redirect to /dashboard):
string ok = TsgcHTMLComponent_OAuthCallback.BuildSuccess(
"Google", "Jane Doe", "/dashboard", "jane@acme.com");
// Error page:
string err = TsgcHTMLComponent_OAuthCallback.BuildError(
"Google", "access_denied");
// Loading / interstitial page:
string wait = TsgcHTMLComponent_OAuthCallback.BuildLoading("Google");
// Full control:
var cb = new TsgcHTMLComponent_OAuthCallback();
cb.Status = TsgcHTMLOAuthCallbackStatus.csSuccess;
cb.ProviderName = "Google";
cb.UserName = "Jane Doe";
cb.UserAvatar = "https://acme.com/u/jane.png";
cb.RedirectURL = "/dashboard";
cb.RedirectMethod = TsgcHTMLOAuthRedirectMethod.rmAutoRedirect;
cb.RedirectDelay = 3;
string html = cb.HTML;
Składniki, po które sięgasz najczęściej.
BuildSuccess(aProviderName, aUserName, aRedirectURL, aUserEmail), BuildError(aProviderName, aErrorMessage) i BuildLoading(aProviderName) renderują gotową stronę w jednym wywołaniu.
Status wybiera csSuccess, csError lub csLoading — znacznik wyboru, krzyżyk lub wskaźnik ładowania, z dopasowaną treścią.
ProviderName, UserName, UserEmail i UserAvatar wypełniają kartę sukcesu; ShowUserInfo i AvatarSize sterują jej wyświetlaniem.
RedirectURL z RedirectMethod (rmAutoRedirect, rmButtonOnly, rmNone) i RedirectDelay sterują nawigacją po zalogowaniu.
SuccessIconColorEnum, ErrorIconColorEnum, SuccessIconText, ErrorIconText (oraz surowe *IconHTML/*IconColor) wraz z MaxWidth nadają styl karcie.
HTML zwraca kartę zwrotną; ErrorMessage wypełnia alert błędu w stanie błędu. Udostępnij ją spod swojego identyfikatora URI przekierowania OAuth.