-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from IoTeaTime/feature/51-kan-104-email-send
feat: Redis를 활용한 이메일 인증 코드 발송 구현
- Loading branch information
Showing
5 changed files
with
90 additions
and
3 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
30 changes: 30 additions & 0 deletions
30
src/main/java/org/ioteatime/meonghanyangserver/config/RedisConfig.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,30 @@ | ||
package org.ioteatime.meonghanyangserver.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
import org.springframework.data.redis.core.RedisKeyValueAdapter; | ||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; | ||
|
||
@Configuration | ||
@EnableRedisRepositories( | ||
enableKeyspaceEvents = RedisKeyValueAdapter.EnableKeyspaceEvents.ON_STARTUP) | ||
public class RedisConfig { | ||
@Value("${spring.data.redis.host}") | ||
private String host; | ||
|
||
@Value("${spring.data.redis.password}") | ||
private String password; | ||
|
||
@Bean | ||
public RedisConnectionFactory redisConnectionFactory() { | ||
RedisStandaloneConfiguration redisConfiguration = new RedisStandaloneConfiguration(); | ||
redisConfiguration.setHostName(host); | ||
redisConfiguration.setPort(6379); | ||
redisConfiguration.setPassword(password); | ||
return new LettuceConnectionFactory(redisConfiguration); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/org/ioteatime/meonghanyangserver/redis/EmailCode.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,18 @@ | ||
package org.ioteatime.meonghanyangserver.redis; | ||
|
||
import lombok.*; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.redis.core.RedisHash; | ||
import org.springframework.data.redis.core.index.Indexed; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@RedisHash(value = "emailCode", timeToLive = 60 * 3) | ||
public class EmailCode { | ||
@Id private Long id; | ||
|
||
@Indexed private String email; | ||
|
||
private String code; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/ioteatime/meonghanyangserver/redis/EmailCodeRepository.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,8 @@ | ||
package org.ioteatime.meonghanyangserver.redis; | ||
|
||
import java.util.Optional; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface EmailCodeRepository extends CrudRepository<EmailCode, String> { | ||
Optional<EmailCode> findByEmail(String email); | ||
} |