Add jwt token on confirmation.

This commit is contained in:
Paulo Gustavo Veiga 2024-03-24 00:15:04 -07:00
parent 3daebd149a
commit 0f4cfcd0d1
2 changed files with 11 additions and 12 deletions

View File

@ -26,15 +26,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
// "config": {
// "apiBaseUrl": "http://localhost:3000",
// "analyticsAccount": "G-RSDEJH16YM",
// "clientType": "mock",
// "recaptcha2Enabled": false,
// "recaptcha2SiteKey": "6Lcat08kAAAAAIP-HjhzIa-Yq21PHgGa_ADWc-Ro",
// "googleOauth2Url": "https: //accounts.google.com/o/oauth2/v2/auth?redirect_uri=https://app.wisemapping.com/c/registration-google&prompt=consent&response_type=code&client_id=625682766634-cocbbbbb403iuvps1evecdk6d7phvbkf.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&access_type=offline&state=wisemapping&include_granted_scopes=true"
// }
@RestController @RestController
@RequestMapping("/api/restful/app") @RequestMapping("/api/restful/app")
public class AppController extends BaseController { public class AppController extends BaseController {

View File

@ -74,16 +74,24 @@ public class OAuth2Controller extends BaseController {
@RequestMapping(method = RequestMethod.PUT, value = "confirmaccountsync", produces = {"application/json"}) @RequestMapping(method = RequestMethod.PUT, value = "confirmaccountsync", produces = {"application/json"})
@ResponseStatus(value = HttpStatus.OK) @ResponseStatus(value = HttpStatus.OK)
public void confirmAccountSync(@NotNull @RequestParam String email, @NotNull @RequestParam String code, @NotNull HttpServletResponse response) throws WiseMappingException { public RestOath2CallbackResponse confirmAccountSync(@NotNull @RequestParam String email, @NotNull @RequestParam String code, @NotNull HttpServletResponse response) throws WiseMappingException {
logger.debug("confirmAccountSync:" + email + "-" + code); logger.debug("confirmAccountSync:" + email + "-" + code);
// Authenticate ... // Authenticate ...
userService.createAndAuthUserFromGoogle(code); final Account user = userService.createAndAuthUserFromGoogle(code);
// Update login // Update login
userService.confirmAccountSync(email, code); userService.confirmAccountSync(email, code);
// Add header ... // Add header ...
jwtTokenUtil.doLogin(response, email); final String jwtToken = jwtTokenUtil.doLogin(response, email);
// Response ...
final RestOath2CallbackResponse result = new RestOath2CallbackResponse();
result.setEmail(user.getEmail());
result.setGoogleSync(false);
result.setSyncCode(user.getSyncCode());
result.setJwtToken(jwtToken);
return result;
} }
} }