This commit is contained in:
Guwan 2024-12-06 21:05:14 +08:00
parent cf74f2b842
commit 31c52d4115
3 changed files with 30 additions and 2 deletions

View File

@ -20,7 +20,9 @@ import org.thymeleaf.context.Context;
@RequiredArgsConstructor
@Validated
public class DemoController {
private final EmailService emailService;
private final RedisUtils redisUtils;
@GetMapping("/getEmailCode")
@ -46,6 +48,7 @@ public class DemoController {
SmsUtils.sendMessage(phone, random);
redisUtils.set(phone, random, 10);
return Result.success();
}

View File

@ -58,8 +58,6 @@ public class UserServiceImpl implements UserService {
User user = new User();
BeanUtils.copyProperties(request, user);
user.setPassword(passwordEncoder.encode(request.getPassword()));
user.setCreatedTime(LocalDateTime.now());

View File

@ -0,0 +1,27 @@
package com.guwan.backend;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.password.PasswordEncoder;
@SpringBootTest
public class Test1 {
private final PasswordEncoder passwordEncoder;
@Autowired
public Test1(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
@Test
void test1() {
System.out.println(passwordEncoder.encode("11"));
//$2a$10$lo6ix.3XY9orNFDBEMDaJuDojHn8yfADjxxRDjUaxG1d.qkDkecJG
System.out.println(passwordEncoder.matches("11", "$2a$10$lo6ix.3XY9orNFDBEMDaJuDojHn8yfADjxxRDjUaxG1d.qkDkecJG"));
}
}