Return token.

main
Paulo Gustavo Veiga 2024-03-23 23:29:48 -07:00
parent 12d67d42ea
commit 3daebd149a
2 changed files with 43 additions and 22 deletions

View File

@ -57,8 +57,10 @@ public class OAuth2Controller extends BaseController {
@ResponseStatus(value = HttpStatus.OK)
public RestOath2CallbackResponse processGoogleCallback(@NotNull @RequestParam String code, @NotNull HttpServletResponse response, @NotNull HttpServletRequest request) throws WiseMappingException {
final Account user = userService.createAndAuthUserFromGoogle(code);
String jwtToken = null;
if (user.getGoogleSync()) {
jwtTokenUtil.doLogin(response, user.getEmail());
jwtToken = jwtTokenUtil.doLogin(response, user.getEmail());
}
// Response ...
@ -66,6 +68,7 @@ public class OAuth2Controller extends BaseController {
result.setEmail(user.getEmail());
result.setGoogleSync(user.getGoogleSync());
result.setSyncCode(user.getSyncCode());
result.setJwtToken(jwtToken);
return result;
}

View File

@ -1,33 +1,51 @@
package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonAutoDetect(
fieldVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
isGetterVisibility = JsonAutoDetect.Visibility.NONE,
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY
)
@JsonIgnoreProperties(ignoreUnknown = true)
public class RestOath2CallbackResponse {
private String email;
private Boolean googleSync;
private String syncCode;
private String email;
private Boolean googleSync;
private String syncCode;
private String jwtToken;
public String getEmail() {
return email;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public void setEmail(String email) {
this.email = email;
}
public Boolean getGoogleSync() {
return googleSync;
}
public Boolean getGoogleSync() {
return googleSync;
}
public void setGoogleSync(Boolean googleSync) {
this.googleSync = googleSync;
}
public void setGoogleSync(Boolean googleSync) {
this.googleSync = googleSync;
}
public String getSyncCode() {
return syncCode;
}
public String getSyncCode() {
return syncCode;
}
public void setSyncCode(String syncCode) {
this.syncCode = syncCode;
}
public void setSyncCode(String syncCode) {
this.syncCode = syncCode;
}
public String getJwtToken() {
return jwtToken;
}
public void setJwtToken(String jwtToken) {
this.jwtToken = jwtToken;
}
}