Search in sources :

Example 6 with PasswordlessMessageBody

use of com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody in project AuthGuard by AuthGuard.

the class SmsPasswordlessSubscriber method onMessage.

@Override
public void onMessage(final Message message) {
    if (message.getEventType() == EventType.PASSWORDLESS_GENERATED) {
        final PasswordlessMessageBody messageBody = (PasswordlessMessageBody) message.getMessageBody();
        final AccountBO account = messageBody.getAccount();
        final AccountTokenDO accountToken = messageBody.getAccountToken();
        sendEmail(account, accountToken);
    }
}
Also used : AccountBO(com.nexblocks.authguard.service.model.AccountBO) AccountTokenDO(com.nexblocks.authguard.dal.model.AccountTokenDO) PasswordlessMessageBody(com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody)

Example 7 with PasswordlessMessageBody

use of com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody in project AuthGuard by AuthGuard.

the class EmailPasswordlessSubscriber method onMessage.

@Override
public void onMessage(final Message message) {
    if (message.getEventType() == EventType.PASSWORDLESS_GENERATED) {
        final PasswordlessMessageBody messageBody = (PasswordlessMessageBody) message.getMessageBody();
        final AccountBO account = messageBody.getAccount();
        final AccountTokenDO accountToken = messageBody.getAccountToken();
        sendEmail(account, accountToken);
    }
}
Also used : AccountBO(com.nexblocks.authguard.service.model.AccountBO) AccountTokenDO(com.nexblocks.authguard.dal.model.AccountTokenDO) PasswordlessMessageBody(com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody)

Example 8 with PasswordlessMessageBody

use of com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody in project AuthGuard by AuthGuard.

the class EmailPasswordlessSubscriberTest method onWrongMessageType.

@Test
void onWrongMessageType() {
    final AccountTokenDO accountToken = AccountTokenDO.builder().token("token").build();
    final AccountBO account = AccountBO.builder().email(AccountEmailBO.builder().email("user@test.net").build()).build();
    final PasswordlessMessageBody messageBody = new PasswordlessMessageBody(accountToken, account);
    final Message message = Messages.passwordlessGenerated(messageBody).withEventType(EventType.ADMIN);
    emailPasswordlessSubscriber.onMessage(message);
    Mockito.verify(emailProvider, Mockito.never()).send(Mockito.any());
}
Also used : AccountBO(com.nexblocks.authguard.service.model.AccountBO) Message(com.nexblocks.authguard.emb.model.Message) AccountTokenDO(com.nexblocks.authguard.dal.model.AccountTokenDO) PasswordlessMessageBody(com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody) Test(org.junit.jupiter.api.Test)

Aggregations

PasswordlessMessageBody (com.nexblocks.authguard.basic.passwordless.PasswordlessMessageBody)8 AccountTokenDO (com.nexblocks.authguard.dal.model.AccountTokenDO)8 AccountBO (com.nexblocks.authguard.service.model.AccountBO)8 Message (com.nexblocks.authguard.emb.model.Message)6 Test (org.junit.jupiter.api.Test)6 ImmutableTextMessage (com.nexblocks.authguard.external.sms.ImmutableTextMessage)3 ImmutableEmail (com.nexblocks.authguard.external.email.ImmutableEmail)1