Skip to content

Commit

Permalink
feat : 비밀번호 이메일로 받아서 유저 비밀번호 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
0702Yoon committed Aug 14, 2024
1 parent d5ba708 commit 789e705
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.example.bigbrotherbe.global.email.EmailVerificationResult;
import com.example.bigbrotherbe.global.jwt.JwtToken;
import com.example.bigbrotherbe.global.jwt.entity.TokenDto;
import com.example.bigbrotherbe.global.security.SecurityConfig;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -30,7 +31,7 @@
import java.util.List;


@RequestMapping("/api/v1/members")
@RequestMapping(SecurityConfig.SERVER+"/members")
@Tag(name = "멤버", description = "회원가입,로그인 API")
public interface MemberController {

Expand Down Expand Up @@ -83,4 +84,8 @@ public interface MemberController {
@DeleteMapping
@Operation(summary = "유저 탈퇴")
ResponseEntity<com.example.bigbrotherbe.global.exception.response.ApiResponse<Void>> memberDeleteSelf();

// @PatchMapping
// ? @Operation(summary = "유저 상세 정보 변경")
// ResponseEntity<com.example.bigbrotherbe.global.exception.response.ApiResponse<MemberInfoResponse>> changeMemberInfo(@RequestBody MemberInfoChangeRequest memberInfoChangeRequest);
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ public ResponseEntity<ApiResponse<EmailVerificationResult>> verificationEmail(St
}



public ResponseEntity<ApiResponse<Void>> changePassword(ChangePasswordRequest changePasswordRequest) {
memberService.changePasswrd(changePasswordRequest.password());
memberService.changePasswrd(changePasswordRequest.email(), changePasswordRequest.password());
return ResponseEntity.ok(ApiResponse.success(SUCCESS));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@



public record ChangePasswordRequest(String password) {
public record ChangePasswordRequest(String email,String password) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface MemberService {

boolean checkExistAffiliationById(Long affiliationId);

void changePasswrd(String password);
void changePasswrd(String email,String password);

void makeAffiliation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ public boolean checkExistAffiliationById(Long affiliationId) {

@Override
@Transactional
public void changePasswrd(String password) {
Member member = authUtil.getLoginMember();
public void changePasswrd(String email,String password) {
Member member = memberLoader.findByMemberEmail(email);
member.changePassword(passwordEncoder.encode(password));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@Component
public class JwtTokenProvider {
private final Key key;
private static final long ACCESS_TIME = 10 * 60 * 100L; // 10분
private static final long ACCESS_TIME = 10 * 6L; // 1초
private static final long REFRESH_TIME = 30 * 60 * 1000L; //30분
public JwtTokenProvider(@Value("${jwt.secret}") String secretKey){
byte[] keyBytes = Decoders.BASE64.decode(secretKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.CsrfConfigurer;
Expand Down Expand Up @@ -40,6 +41,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.requestMatchers(SERVER+"/members/sign-in").permitAll()
.requestMatchers(SERVER+"/members/sign-up/**").permitAll()
.requestMatchers(SERVER+"/members/refresh").permitAll()
.requestMatchers(HttpMethod.PATCH,SERVER+"/members").permitAll()
// USER 권한이 있어야 요청할 수 있음
.requestMatchers(SERVER+"/members/test").hasRole("USER")
.requestMatchers(SERVER+"/members/manager").hasRole("ADMIN")
Expand Down

0 comments on commit 789e705

Please sign in to comment.