当前位置:网站首页>抖音实战~密码找回
抖音实战~密码找回
2022-06-23 22:20:00 【gblfy】

1. 密码找回流程图

2. 前端源码
/**
* 密码找回
*/
updatePassword() {
var me = this;
var mobile = me.mobile;
// 提交前,手机号校验
var reg = /^1[0-9]{
10,10}$/;
if (!mobile || !reg.test(mobile)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
})
return
}
if (!this.agree) {
uni.showToast({
title: '请先同意《隐私及服务协议》',
icon: 'none'
});
return;
}
var serverUrl = app.globalData.serverUrl;
// 密码找回
var password = me.password;
if (app.isStrEmpty(password)) {
uni.showToast({
title: "新密码不能为空",
icon: "none"
});
return;
}
console.log("forgotPassword")
// uni.showLoading()
// 调用后端登录注册
uni.request({
method: "POST",
url: serverUrl + "/user/forgotPassword",
data: {
"mobile": mobile,
"smsCode": me.verifyCode,
"newPassword": password
},
success(result) {
console.log("result", result)
var status = result.data.status;
if (status != 200) {
uni.showToast({
title: result.data.msg,
icon: "none",
duration: 3000
});
}
if (status == 200) {
uni.navigateTo({
url: '../loginRegist/loginRegist'
})
uni.showToast({
title: result.data.msg,
icon: "none",
duration: 3000
});
// 登录成功,跳转登录页,关闭当前页
}
}
});
}
3. 后端
/**
* 重置密码
*
* @param forgotPasswordBO 手机号 + 验证码+新密码
*/
@PostMapping("forgotPassword")
public GraceJSONResult forgotPassword(@Valid @RequestBody ForgotPasswordBO forgotPasswordBO,
HttpServletRequest request) {
String mobile = forgotPasswordBO.getMobile();
String code = forgotPasswordBO.getSmsCode();
String newPassword = forgotPasswordBO.getNewPassword();
// 1. 从redis中获得验证码进行校验是否匹配
String redisCode = redis.get(MOBILE_SMSCODE + ":" + mobile);
if (StringUtils.isBlank(redisCode) || !redisCode.equalsIgnoreCase(code)) {
return GraceJSONResult.errorCustom(ResponseStatusEnum.SMS_CODE_ERROR);
}
// 2. 查询数据库,判断用户是否存在
Users user = userService.queryMobileIsExist(mobile);
if (user == null) {
return GraceJSONResult.errorCustom(ResponseStatusEnum.ACCOUNT_NOT_EXIST);
}
this.userService.forgotPassword(mobile, newPassword);
//重置密码成功,将验证码删除
redis.del(MOBILE_SMSCODE + ":" + mobile);
return GraceJSONResult.ok(ResponseStatusEnum.RESET_PASSWORD_SUCCESS);
}
拦截器放过

边栏推荐
- 1. < tag dynamic programming and path combination problem > lt.62 Different paths + lt.63 Different paths II
- What are the good solutions for industrial control safety of production line
- Total number of combinations ii[each element can only be solved by + once]
- [things about gbase] gbase 8s high availability technology and case analysis (issue 02)
- Differences between broadcastreceiver and localbroadcastmanager
- 点乘和叉乘
- 依赖倒置原则
- Acrel-3000WEB电能管理系统在都巴高速的应用
- APP性能优化之启动流程分析
- 入参参数为Object,但传递过去却成了[object object] 是因为需要转为JSON格式
猜你喜欢

This high imitation millet mall project is amazing

多门店药品进销存系统源码 大型连锁药店管理系统源码

Docker Deployment redis

【Proteus仿真】T6963C驱动PG12864示例(带中英文显示)

Generative countermeasure networks (Gans) and variants

跟着CTF-wiki学pwn——ret2text

Digital property management has become a trend. How can traditional property companies achieve digital butterfly change through transformation?
![Restore IP address [standard backtracking + standard pruning]](/img/e6/5f9d2a5af973b6c7051ed434a4b93d.png)
Restore IP address [standard backtracking + standard pruning]

完整开源项目之诗词吧 APP

How to achieve the turning effect of wechat video recording?
随机推荐
EF Core中的三类事务(SaveChanges、DbContextTransaction、TransactionScope)
What kind of automated test is used for H5 mobile terminal
Don't miss | Huawei's internal data - Successful Project Management PPT (page 123)
【Proteus仿真】T6963C驱动PG12864示例(带中英文显示)
Goodbye, 2020, this bowl of poisonous chicken soup, I'll dry it first
Golang type assertion
Nice input edit box
Unity text component space newline problem
WPF效果之Expander+ListBox
Facebook open source shimmer effect
docker redis集群配置
Leetcode - linked list written test questions
1. < tag dynamic programming and path combination problem > lt.62 Different paths + lt.63 Different paths II
不同物体使用同一材质,有不同的表现
Wechat applet picture verification code display
Three cool and coquettish bottom navigation
医疗是什么?AI医疗概念解析AI
如何利用数仓创建时序表
AutoCAD -- summarize three methods of drawing rounded corners in CAD
组合总数II[每个元素只能用一次 + 去重复解集]