Class accountService

java.lang.Object
vn.edu.uit.csbu.software_design.software_design_backend.account.accountService

@Service public class accountService extends Object
The `accountService` class in Java provides various methods for managing user accounts, including authentication, account creation, updating account details, and deleting accounts.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<accountResponseDTO>
    The `deleteAccount` function deletes an account and related data if it exists based on the provided token.
    org.springframework.http.ResponseEntity<accountResponseDTO>
    The function `updateDescription` takes a token and optional data to update the description of an account, checking for XSS attacks before saving the changes.
    org.springframework.http.ResponseEntity<accountResponseDTO>
    The function `updatePassword` takes a token and optional password data, updates the password for the account associated with the token, and returns a response entity with the result.
    org.springframework.http.ResponseEntity<accountResponseDTO>
    The function `updateTitle` takes a token and optional data to update the title of an account, checking for XSS attacks before saving the changes and returning a response.
    org.springframework.http.ResponseEntity<accountResponseDTO>
    The function `updateUsername` takes a token and optional data to update the username in the database, handling XSS detection and existing username conflicts.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • accountService

      public accountService()
  • Method Details

    • updateTitle

      public org.springframework.http.ResponseEntity<accountResponseDTO> updateTitle(String token, Optional<String> data)
      The function `updateTitle` takes a token and optional data to update the title of an account, checking for XSS attacks before saving the changes and returning a response.
      Parameters:
      token - A token is a piece of data that is used to authenticate a user and provide access to a system or service. It is often used in web applications to verify the identity of a user before allowing them to perform certain actions. In this context, the token is likely a JWT (JSON Web Token)
      data - The `data` parameter in the `updateTitle` method is an optional string that represents the new title that you want to update for an account. If the `data` parameter is present and not empty, the method will update the title of the account with the provided data. If the `data
      Returns:
      The method `updateTitle` returns a `ResponseEntity` containing an `accountResponseDTO`. The response can have different HTTP status codes and messages based on the conditions checked in the method. If the update is successful, it returns a response with status code 200 (OK) and a message "Title Updated". If there is a security concern with XSS detected in the data, it returns a response
    • updateDescription

      public org.springframework.http.ResponseEntity<accountResponseDTO> updateDescription(String token, Optional<String> data)
      The function `updateDescription` takes a token and optional data to update the description of an account, checking for XSS attacks before saving the changes.
      Parameters:
      token - A token is a piece of data that is used to authenticate a user and provide access to a system or service. It is often used in web applications to verify the identity of a user before allowing them to perform certain actions. In this context, the token is likely a JWT (JSON Web Token)
      data - The `data` parameter in the `updateDescription` method is an optional string that represents the new description that will be updated for the account. It is passed as an optional to handle cases where the description data may be null. If the `data` parameter is present and not null, the method
      Returns:
      The method `updateDescription` returns a `ResponseEntity` containing an `accountResponseDTO` object. The response can have different HTTP status codes and messages based on the conditions met in the method:
    • updatePassword

      public org.springframework.http.ResponseEntity<accountResponseDTO> updatePassword(String token, Optional<String> data)
      The function `updatePassword` takes a token and optional password data, updates the password for the account associated with the token, and returns a response entity with the result.
      Parameters:
      token - A token used for authentication and authorization purposes.
      data - The `data` parameter in the `updatePassword` method represents the new password that the user wants to update in their account. It is an optional parameter, meaning it may or may not be present when the method is called. If present, the method will update the password for the account associated with
      Returns:
      A `ResponseEntity` object with a `accountResponseDTO` containing a message indicating whether the password was updated successfully or if there was an issue (such as XSS detection or missing data). The HTTP status code of the response varies based on the outcome (OK for successful update, NOT_ACCEPTABLE for XSS detection, and BAD_REQUEST for missing account or password data).
    • updateUsername

      public org.springframework.http.ResponseEntity<accountResponseDTO> updateUsername(String token, Optional<String> data)
      The function `updateUsername` takes a token and optional data to update the username in the database, handling XSS detection and existing username conflicts.
      Parameters:
      token - A token is a piece of data that is used to authenticate a user and provide access to a system or service. In this context, the token is likely a JWT (JSON Web Token) that contains information about the user's identity and permissions. It is extracted using the `JWTUtil.extractName(token
      data - The `data` parameter in the `updateUsername` method represents the new username that you want to update for the account. It is an optional parameter, meaning it may or may not have a value. If it has a value, the method will attempt to update the username of the account with the
      Returns:
      This method returns a `ResponseEntity` containing an `accountResponseDTO` object. The response can have different HTTP status codes and corresponding messages based on the conditions checked in the method:
    • deleteAccount

      public org.springframework.http.ResponseEntity<accountResponseDTO> deleteAccount(String token)
      The `deleteAccount` function deletes an account and related data if it exists based on the provided token.
      Parameters:
      token - The `token` parameter in the `deleteAccount` method is a string that represents the authentication token used to identify the user account that is being deleted. This token is typically generated during the user authentication process and is used to authorize and authenticate the user's actions.
      Returns:
      The method `deleteAccount` returns a `ResponseEntity` object with a generic type of `accountResponseDTO`. The response body contains a message indicating whether the account was successfully deleted or if no account was found. The HTTP status code of the response is either 200 (OK) if the account was deleted, or 404 (NOT FOUND) if no account was found.