Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix auth user json parse #4

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.marketplace.app.security;

import java.util.HashMap;
import java.util.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -12,6 +13,7 @@
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClient;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.marketplace.domain.ApplicationException;

Expand Down Expand Up @@ -61,10 +63,10 @@ public AuthUser getUserData(String idToken) {
var root = array.next();

var result = new AuthUser();
result.setUid(root.get("localId").asText());
result.setName(root.get("displayName").asText());
result.setEmail(root.get("email").asText(null));
result.setImageUrl(root.get("photoUrl").asText(null));
result.setUid(root.get("localId").textValue());
result.setName(root.get("displayName").textValue());
result.setEmail(Optional.ofNullable(root.get("email")).map(JsonNode::textValue).orElse(null));
result.setImageUrl(Optional.ofNullable(root.get("photoUrl")).map(JsonNode::textValue).orElse(null));
return result;
} catch (Exception e) {
log.error("Fetch user error: {}", e.getMessage());
Expand Down
35 changes: 35 additions & 0 deletions marketplace-application/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
spring:
config:
import: classpath:env.production.yml
datasource:
url: ${app.database.url}
username: ${app.database.username}
password: ${app.database.password}
jpa:
hibernate:
ddl-auto: update
show-sql: false
properties:
"[hibernate.format_sql]": true
open-in-view: false

servlet.multipart:
max-file-size: 20MB
max-request-size: 20MB
location: ${java.io.tmpdir}

jackson:
default-property-inclusion: non-null

security:
oauth2:
resourceserver:
jwt:
jwk-set-uri: ${app.firebase.jwk-set-uri}
issuer-uri: ${app.firebase.issuer-uri}

springdoc:
swagger-ui:
enabled: false
api-docs:
enabled: false