-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 기존에는 Google OAuth를 이용해서 비밀번호를 사용하지 않다가, 시나브로 로그인/회원가입을 위해서 유저 비밀번호 컬럼을 추가했어요.
- Loading branch information
Showing
4 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/bamdoliro/sinabro/domain/user/domain/value/Password.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.bamdoliro.sinabro.domain.user.domain.value; | ||
|
||
import com.bamdoliro.sinabro.shared.util.PasswordUtil; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
@Embeddable | ||
public class Password { | ||
|
||
@Column(name = "password", length = 60) | ||
private String value; | ||
|
||
public boolean match(String password) { | ||
return PasswordUtil.matches(value, password); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/bamdoliro/sinabro/shared/util/PasswordUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.bamdoliro.sinabro.shared.util; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
|
||
@UtilityClass | ||
public class PasswordUtil { | ||
|
||
private static final PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); | ||
|
||
public boolean matches(String actual, String expected) { | ||
return passwordEncoder.matches(expected, actual); | ||
} | ||
|
||
public String encode(String password) { | ||
return passwordEncoder.encode(password); | ||
} | ||
} |