Skip to content

Commit 92d3795

Browse files
committed
通过邮箱修改密码
1 parent 2fb0044 commit 92d3795

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

springboot-dubbo-service/src/main/java/com/lzq/dubboservice/service/AccountServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ public void insert(Account account) {
3939
public Boolean update(Account account){
4040
QueryWrapper<Account> wrapper = new QueryWrapper<>();
4141
//当同时存在时则修改邮箱
42-
wrapper.eq("username",account.getUsername());
42+
if (StringUtils.isNotBlank(account.getUsername())){
43+
wrapper.eq("username",account.getUsername());
44+
}else if (!StringUtils.isNotBlank(account.getUsername())
45+
&& StringUtils.isNotBlank(account.getEmail())){
46+
//当用户名为空邮箱不为空时修改密码
47+
wrapper.eq("email",account.getEmail());
48+
}
49+
4350
return baseMapper.update(account,wrapper)>0?true:false;
4451
}
4552

springboot-dubbo-web/src/main/java/com/lzq/web/config/UserDetailConfig.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,16 @@ public class UserDetailConfig implements UserDetailsService {
2929

3030
@Override
3131
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
32-
log.info(s);
32+
log.info("我进入了登录登录逻辑");
3333
//生产用户
3434
Account account = null;
3535
//判断用户所用账号为邮箱还是用户名
3636
if (s.split("\\.").length > 1) {
3737
//根据邮箱查询用户
3838
account = accountService.queryByEmail(s);
39-
log.info(account.toString());
4039
} else {
4140
//根据用户名查询用户
4241
account = accountService.queryByUsername(s);
43-
log.info(account.toString());
4442
}
4543
if (account == null) {
4644
throw new UsernameNotFoundException("账号或密码错误");

springboot-dubbo-web/src/main/java/com/lzq/web/controller/IndexController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public Map<String, Object> sendPasswordEmail(Account account) {
196196
@PutMapping("/modifyPossword")
197197
@ApiOperation("修改用户密码")
198198
public Map<String, Object> modifyPossword(HttpServletRequest request, Account account) {
199+
log.info("进入了修改密码接口");
199200
//接收发送过来的token
200201
String token = request.getHeader("token");
201202
//判断token是否存在
@@ -210,7 +211,8 @@ public Map<String, Object> modifyPossword(HttpServletRequest request, Account ac
210211
account.setEmail(email);
211212
//更新密码
212213
Boolean update = accountService.update(account);
213-
return ResultMapUtils.ResultMap(true, 0, null);
214+
log.info("修改:"+Boolean.toString(update));
215+
return ResultMapUtils.ResultMap(update, 0, null);
214216
} else {
215217

216218
}

0 commit comments

Comments
 (0)