Class AuthPasswordResetServiceImpl

    • Method Detail

      • computeEnabled

        protected boolean computeEnabled()
      • consumeTokens

        protected void consumeTokens​(User user)
        Consumes existing password reset tokens for the given user.
        Parameters:
        user - the user whose password needs to be reset
      • sendEmail

        protected void sendEmail​(User user)
                          throws MailException
        Sends a password reset email to the given user.
        Parameters:
        user - the user whose password needs to be reset
        Throws:
        MailException
      • getEmailSubject

        protected String getEmailSubject​(User user)
        Gets the subject of the password reset email.
        Parameters:
        user - the user whose password needs to be reset
        Returns:
        the subject of the email
      • getEmailBody

        protected String getEmailBody​(User user,
                                      String resetUrl)
        Gets the body of the password reset email.
        Parameters:
        user - the user whose password needs to be reset
        resetUrl - the password reset URL
        Returns:
        the body of the email
      • createResetUrl

        protected String createResetUrl​(User user)
        Creates a password reset URL.
        Parameters:
        user - the user whose password needs to be reset
        Returns:
        the password reset URL
      • createToken

        protected String createToken​(User user)
        Creates a password reset token.
        Parameters:
        user - the user whose password needs to be reset
        Returns:
        the password reset token
        Throws:
        IllegalStateException - if the user is not active
      • getValidToken

        protected PasswordResetToken getValidToken​(String token)
        Gets a password reset token record if it is valid.

        Checks whether it exists, not archived, not consumed, not expired, and user is active.

        Parameters:
        token - the password reset token
        Returns:
        the password reset token record
        Throws:
        IllegalArgumentException - if the token is invalid
      • getMaxAgeHours

        protected static int getMaxAgeHours()
        Gets the maximum age of a password reset token in hours.
        Returns:
        the maximum age in hours
      • getBaseUrl

        protected String getBaseUrl​(boolean trimSlash)
        Gets the base URL of the application.

        We cannot trust request host header because of host header injection attacks. We use either `application.base-url` or current tenant `hosts` configuration.

        Returns:
        the base URL
      • getBaseUrl

        protected String getBaseUrl()
      • getTenantBaseUrl

        @Nullable
        protected String getTenantBaseUrl​(String tenantId)
      • getHttpRequest

        protected javax.servlet.http.HttpServletRequest getHttpRequest()