• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Bh

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Based on the code you've provided, here are the specific changes needed to implement the ID verification flow:

1. DigitalIdentityVerificationView.js


$initiateButton.click(function() {
var selectedEmail = $emailSelect.val();
var errorMessages = [];

// Validate selected email
if (!selectedEmail) {
errorMessages.push(global.Messages.get("msg.DIV.EmailAddress.required"));
displayMessages(errorMessages);
return false;
}

// Step 1: Set the ID verification flag via AJAX
$.ajax({
url: '/myclient/oauth/prepare-id-verify',
method: 'POST',
data: {
emailForDiv: selectedEmail,
crossRefId: clientData.crossRefId // Assuming you have clientData available
},
success: function(response) {
// Step 2: Redirect to OAuth flow after flag is set
window.location.href = authUtil.prepareAuthorizationUrl(mycEcifProperties);
},
error: function(xhr) {
displayMessages(["Failed to initiate ID verification. Please try again."]);
}
});

return false;
});
2. EcfTokenController.java


// New pre-flight endpoint to set the ID verification flag
@RequestMapping(value = "/oauth/prepare-id-verify", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> prepareIdVerify(HttpServletRequest request,
@RequestParam("emailForDiv") String emailForDiv,
@RequestParam("crossRefId") String crossRefId) {
HttpSession session = request.getSession();

// Set the flag to indicate ID verification flow
session.setAttribute("OAUTH_FLOW_INTENT", "ID_VERIFY");

// Store data needed for ID verification later
session.setAttribute("ID_VERIFY_EMAIL", emailForDiv);
session.setAttribute("ID_VERIFY_CROSS_REF", crossRefId);

// Return success
Map<String, String> response = new HashMap<>();
response.put("status", "ok");
return response;
}

// Modify existing authRedirectAD method
@RequestMapping(value = "/authRedirectAD", method = RequestMethod.GET)
public ModelAndView authRedirectAD(final HttpServletRequest httpReq,
final HttpServletResponse httpResp,
final @RequestParam("code") String code,
final @RequestParam("state") String state)
throws IOException {
// Existing code
Map<String, String> result = new HashMap<>();
result.put("tokenStatus", "not there");
Boolean isStateInternalUrl = false;

String tempCode = code;

// ... rest of your existing validation code ...

// Before processing the code normally, check if this is an ID verification flow
HttpSession session = httpReq.getSession(false);
String flowIntent = (String) session.getAttribute("OAUTH_FLOW_INTENT");

if (flowIntent != null && "ID_VERIFY".equals(flowIntent)) {
// Clear the flag
session.removeAttribute("OAUTH_FLOW_INTENT");

// Get stored data for ID verification
String emailForDiv = (String) session.getAttribute("ID_VERIFY_EMAIL");
String crossRefId = (String) session.getAttribute("ID_VERIFY_CROSS_REF");

// Clear the stored data
session.removeAttribute("ID_VERIFY_EMAIL");
session.removeAttribute("ID_VERIFY_CROSS_REF");

// Build the redirect URL with parameters
StringBuilder redirectUrl = new StringBuilder();
redirectUrl.append("/myclient/client/idVerify");
redirectUrl.append("?authCode=").append(URLEncoder.encode(code, "UTF-8"));
redirectUrl.append("&emailForDiv=").append(URLEncoder.encode(emailForDiv, "UTF-8"));
redirectUrl.append("&crossRefId=").append(URLEncoder.encode(crossRefId, "UTF-8"));

// Redirect to the ID verification endpoint
httpResp.sendRedirect(redirectUrl.toString());

LoggerUtil.debug(logger, message: "EcifTokenController.authRedirectAD() api call ended - redirecting for ID verification");
LoggerUtil.log(logger, tracker);
return null;
}

// Continue with normal authentication flow for non-ID verification
// ... rest of your existing code ...

if (isStateInternalUrl == false) {
LoggerUtil.debug(logger, message: "authorization code {}", tempCode);
HttpSession session = httpReq.getSession(create:false);
boolean isJwtTokenSet = authUtil.setJwtTokenInSession(session, mycEcifProperties, tempCode, AuthUtil.setUpRedirectUrl(httpReq, "/myc/"+ControllerConstants.AUTH_REDIRECT_AD));
// ... rest of your existing code ...
} else if (isStateInternalUrl == true) {
// ... your existing code ...
}

// ... rest of your method ...
}
3. ClientController.java - No changes needed


Your existing ClientController.initIDVerification method already accepts an authCode parameter, so no changes are required there. It will continue working as is, accepting the auth code passed from the EcfTokenController.

These changes implement the plan we discussed while minimizing modifications to the existing code. The main logic is:

  1. When the ID verify button is clicked, set a flag in the session via AJAX
  2. Redirect to the standard OAuth flow
  3. When the auth code comes back to authRedirectAD, check if the ID verify flag is set
  4. If yes, redirect to your ID verification endpoint with the auth code and other data
  5. Your existing ID verification method handles the auth code processing


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу