Skip to content

Commit

Permalink
email @handong.edu add #53 (#54)
Browse files Browse the repository at this point in the history
* email @handong.edu add #53

* refix @edu email #53

* Fix email code fixes #53

* Change format
  • Loading branch information
Sangdeveloper7 authored Nov 22, 2024
1 parent de110ba commit 4ea7c89
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions src/main/java/app/handong/feed/service/impl/TbuserServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ public class TbuserServiceImpl implements TbuserService {
@Autowired
private final TbuserRepository tbuserRepository;
private final GoogleAuthService googleAuthService;



public TbuserServiceImpl(TbuserRepository tbuserRepository, GoogleAuthService googleAuthService) {
this.tbuserRepository = tbuserRepository;
this.googleAuthService = googleAuthService;
}


@Override
public TbuserDto.DetailResDto detail(DefaultDto.DetailReqDto param) {
// TODO: implement detail
Expand All @@ -53,7 +51,6 @@ public Map<String, Object> create(Map<String, Object> params) {
return returnMap;
}


@Override
public TbuserDto.CreateResDto access(String param) throws Exception {
TokenFactory tokenFactory = new TokenFactory();
Expand All @@ -62,7 +59,6 @@ public TbuserDto.CreateResDto access(String param) throws Exception {
return null;
}


@Override
public TbuserDto.CreateResDto loginWithGoogle(String credential) {
String[] out = googleAuthService.verifyGoogleToken(credential);
Expand All @@ -75,34 +71,31 @@ public TbuserDto.CreateResDto loginWithGoogle(String credential) {
System.out.println("email string is " + email);
System.out.println("email name is " + name);

// 유저 객체 생성


boolean checkHandongPeople = false;
// 유저가 @handong.ac.kr 이메일이 아니면 예외 처리
if (email == null || !email.endsWith("@handong.ac.kr")) {
throw new NoAuthorizationException("Not Handong User");
if (email != null) {
if (email.endsWith("@handong.ac.kr")) {
checkHandongPeople = true;
} else if (email.endsWith("@handong.edu")) {
checkHandongPeople = true;
}
}

Tbuser tbuser = tbuserRepository.findByEmail(email);

if (tbuser != null) {
// 유저가 있으면 이메일 출력
System.out.println("user " + tbuser.getEmail());
tbuser.setLast_login_time(now);
if (!checkHandongPeople) {
throw new NoAuthorizationException("Not Handong User");
} else {
tbuser = Tbuser.of(email, uuid, name, now, now, now);
// 유저가 없는 경우 신규 가입
Tbuser tbuser = tbuserRepository.findByEmail(email);

if (tbuser != null) {
// 유저가 있으면 이메일 출력
System.out.println("user " + tbuser.getEmail());
tbuser.setLast_login_time(now);
} else {
tbuser = Tbuser.of(email, uuid, name, now, now, now);
// 유저가 없는 경우 신규 가입
}
tbuserRepository.save(tbuser);
return TbuserDto.CreateResDto.builder().uid(tbuser.getId()).email(email).build();
}
tbuserRepository.save(tbuser);

// Map<String, Object> params = new HashMap<>();
// params.put("email", email);
// params.put("uuid", uuid);
// params.put("name", name);
//
// Map<String, Object> createResult = create(params);

return TbuserDto.CreateResDto.builder().uid(tbuser.getId()).email(email).build();
}


Expand Down

0 comments on commit 4ea7c89

Please sign in to comment.