Search in sources :

Example 1 with NoSuchPersistentLoginException

use of org.craftercms.profile.exceptions.NoSuchPersistentLoginException in project profile by craftercms.

the class AuthenticationServiceImpl method refreshPersistentLoginToken.

@Override
public PersistentLogin refreshPersistentLoginToken(String loginId) throws ProfileException {
    PersistentLogin login = getPersistentLogin(loginId);
    if (login != null) {
        try {
            login.setToken(UUID.randomUUID().toString());
            persistentLoginRepository.save(login);
            logger.debug(LOG_KEY_PERSISTENT_LOGIN_TOKEN_REFRESHED, loginId, login.getToken());
            return login;
        } catch (MongoDataException e) {
            throw new I10nProfileException(ERROR_KEY_UPDATE_PERSISTENT_LOGIN_ERROR, loginId);
        }
    } else {
        throw new NoSuchPersistentLoginException(loginId);
    }
}
Also used : I10nProfileException(org.craftercms.profile.api.exceptions.I10nProfileException) NoSuchPersistentLoginException(org.craftercms.profile.exceptions.NoSuchPersistentLoginException) MongoDataException(org.craftercms.commons.mongo.MongoDataException) PersistentLogin(org.craftercms.profile.api.PersistentLogin)

Aggregations

MongoDataException (org.craftercms.commons.mongo.MongoDataException)1 PersistentLogin (org.craftercms.profile.api.PersistentLogin)1 I10nProfileException (org.craftercms.profile.api.exceptions.I10nProfileException)1 NoSuchPersistentLoginException (org.craftercms.profile.exceptions.NoSuchPersistentLoginException)1