src/main/java/com/feljtech/istudybucket/business/service/impl/AuthServiceImpl.java
/**
     * implementation for user verification
     * @param verificationTokenValue: token value
     * @param username: username concerned
     * @return: logic state of user verification
     */
implementation for user verification
@param verificationTokenValue: token value
@param username: username concerned
@return: logic state of user verification
implementation for user verification @param verificationTokenValue : token value @param username : username concerned @return : logic state of user verification
@Override
    @Transactional
    public boolean verifyAccount(String verificationTokenValue, String username) {
        AtomicBoolean verTokenValid = new AtomicBoolean(false);
        Optional<VerificationToken> verificationTokenOpt = verificationTokenRepository.findByTokenValue(verificationTokenValue);
        verificationTokenOpt.ifPresent(verificationToken -> {
            verTokenValid.set(verificationToken.getUsername().equals(username));
            Optional<User> userToBeVerified = userRepository.findByUsername(verificationToken.getUsername());
            userToBeVerified.ifPresent(user -> {
                boolean userUpdated = false;
                if(verTokenValid.get()) {
                    userUpdated = updateUserVerification(user, verTokenValid.get());
                }
                if(userUpdated) verificationTokenRepository.deleteById(verificationToken.getTokenId());
            });
        });
        return verTokenValid.get();
    }
@ Override @ Transactional public boolean verifyAccount ( String verificationTokenValue , String username ) { AtomicBoolean verTokenValid = new AtomicBoolean ( false ) ; Optional < VerificationToken > verificationTokenOpt = verificationTokenRepository . findByTokenValue ( verificationTokenValue ) ; verificationTokenOpt . ifPresent ( verificationToken -> { verTokenValid . set ( verificationToken . getUsername ( ) . equals ( username ) ) ; Optional < User > userToBeVerified = userRepository . findByUsername ( verificationToken . getUsername ( ) ) ; userToBeVerified . ifPresent ( user -> { boolean userUpdated = false ; if ( verTokenValid . get ( ) ) { userUpdated = updateUserVerification ( user , verTokenValid . get ( ) ) ; } if ( userUpdated ) verificationTokenRepository . deleteById ( verificationToken . getTokenId ( ) ) ; } ) ; } ) ; return verTokenValid . get ( ) ; }
implementation for user verification
 @param verificationTokenValue: token value
 @param username: username concerned
 @return: logic state of user verification
implementation for user verification @param verificationTokenValue : token value @param username : username concerned @return : logic state of user verification
// extract optional verification token from the db // set the account valid value based on the verification // get the Optional value for the user from the userRep object // if user is present, perform the action declared, // pass call to update the user's verification // delete the verification token if the operation was successful