All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.foodtechlab.lib.auth.service.domain.token.usecases.ExpireAccessTokenByTimeUseCase Maven / Gradle / Ivy

There is a newer version: 4.1.0
Show newest version
package ru.foodtechlab.lib.auth.service.domain.token.usecases;

import com.rcore.domain.commons.usecase.UseCase;
import com.rcore.domain.commons.usecase.model.IdInputValues;
import com.rcore.domain.commons.usecase.model.SingletonEntityOutputValues;
import lombok.RequiredArgsConstructor;
import ru.foodtechlab.lib.auth.service.domain.token.entity.AccessTokenEntity;
import ru.foodtechlab.lib.auth.service.domain.token.exception.AccessTokenNotFoundException;
import ru.foodtechlab.lib.auth.service.domain.token.port.AccessTokenRepository;

import java.time.Instant;

@RequiredArgsConstructor
public class ExpireAccessTokenByTimeUseCase extends UseCase, SingletonEntityOutputValues> {

    private final AccessTokenRepository accessTokenRepository;

    @Override
    public SingletonEntityOutputValues execute(IdInputValues inputValues) {

        AccessTokenEntity accessTokenEntity = accessTokenRepository.findById(inputValues.getId())
                .orElseThrow(AccessTokenNotFoundException::new);

        accessTokenEntity.setExpireAt(Instant.now());

        return SingletonEntityOutputValues.of(accessTokenRepository.save(accessTokenEntity));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy