/** * Returns the QR code for the user if two factor is enabled. * * @param user * @param password * @param req * @return null if two factor is disabled. * @throws AppException */ public byte[] getQRCode(Users user, String password, HttpServletRequest req) throws AppException { byte[] qr_code = null; if (user == null) { throw new AppException(Response.Status.NOT_FOUND.getStatusCode(), ResponseMessages.USER_WAS_NOT_FOUND); } if (!authController.validatePassword(user, password, req)) { throw new AppException(Response.Status.BAD_REQUEST.getStatusCode(), ResponseMessages.PASSWORD_INCORRECT); } if (user.getTwoFactor()) { try { qr_code = QRCodeGenerator.getQRCodeBytes(user.getEmail(), Settings.ISSUER, user.getSecret()); } catch (IOException | WriterException ex) { LOGGER.log(Level.SEVERE, null, ex); } } return qr_code; }
userFacade.update(user); qr_code = QRCodeGenerator.getQRCodeBytes(user.getEmail(), Settings.ISSUER, user.getSecret()); accountAuditFacade.registerAccountChange(user, AccountsAuditActions.TWO_FACTOR.name(), AccountsAuditActions.SUCCESS.name(), "Enabled 2-factor", user,
qrCode = QRCodeGenerator.getQRCodeBytes(newUser.getEmail(), Settings.ISSUER, user.getSecret()); accountAuditFacade.registerAccountChange(user, AccountsAuditActions.REGISTRATION.name(), AccountsAuditActions.SUCCESS.name(), "", user, req);