Creates an instance of AuthService. Sets up token handling and retrieves user data if a token exists in local storage.
Checks if a user is currently logged in.
True if the user is logged in, false otherwise
Provides an observable stream of the current user data. Used for components to react to changes in user authentication state.
An Observable of the current user data
Changes a user's email address and updates the authentication token.
Current email address of the user
New email address to change to
A Promise resolving with a success message or rejecting with error
Initiates the forgot password process.
Email address of the user requesting password reset
A Promise resolving with a success message or rejecting with error
Gets the current user data as a snapshot.
The current user data or undefined if not logged in
Authenticates a user and stores the received token.
Email address of the user
Password for authentication
A Promise resolving on successful login or rejecting with error
Logs out the current user by removing the token. This clears the authentication state and user data.
Updates the authentication token. Used when receiving a new token from the server after certain operations.
The new JWT token to set
Registers a new user in the system.
Email address of the user
First name of the user
Last name of the user
Password for the account
An Observable from the HTTP request
Resets a user's password using a token.
Reset token received via email
New password to set
A Promise resolving with a success message or rejecting with error
Service responsible for authentication and user session management in the frontend. Handles user login, registration, token management, and profile operations.