Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dreancaste/TriviaPP/llms.txt
Use this file to discover all available pages before exploring further.
AuthService is the single point of contact for all identity operations in TriviaPP. It wraps the AWS Amplify v6 aws-amplify/auth primitives — signUp, confirmSignUp, signIn, signOut, getCurrentUser, and fetchAuthSession — behind a clean Angular service interface. It also holds the authenticated user’s email address in memory so that other services can read it synchronously via the userEmail getter without needing to hit Cognito on every call.
For Amplify and Cognito project configuration, see the AWS Amplify Auth configuration guide.
Constructor / Dependencies
AuthService is provided in the root injector (providedIn: 'root') and has no constructor dependencies — it uses the top-level Amplify auth functions directly.
Methods
register()
Registers a new user in the Cognito User Pool. Delegates to Amplify’s signUp(), passing the email as the username.
The user’s email address. Used as the Cognito
username.The account password. Must meet the Cognito password policy configured for the User Pool.
confirmarRegistro() to complete sign-up.
confirmarRegistro()
Confirms a pending registration using the six-digit code that Cognito emailed to the user.
The email address supplied during
register().The confirmation code received by email.
If the code has expired, Cognito can resend it via
resendSignUpCode(). That utility is not wrapped by AuthService — call it directly from aws-amplify/auth if needed.login()
Signs the user in with email and password. On success, caches the email in currentEmail so that userEmail can return it without an additional async call.
The registered email address.
The account password.
SignInOutput includes an isSignedIn boolean and a nextStep descriptor. If isSignedIn is false, the user may need to complete an MFA or new-password challenge described in nextStep.
logout()
Signs the user out globally and clears the in-memory currentEmail.
logout() invalidates the Amplify session tokens locally. No parameters are required.
getCurrentUser()
Retrieves the currently authenticated Cognito user. Updates currentEmail from signInDetails.loginId on success; clears it and returns null if no session is active.
AppComponent.ngOnInit). Returns null rather than throwing when the user is not signed in.
obtenerTokenJWT()
Fetches the current Amplify auth session and returns the raw string representation of the Cognito ID token, which can be forwarded as a Bearer token to backend services.
null if the session cannot be fetched (unauthenticated, expired, network error).
userEmail (getter)
Returns the in-memory cached email of the currently signed-in user. Does not make a network call.
'' when no user is signed in.