当前位置:网站首页>抖音实战~密码找回
抖音实战~密码找回
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);
}
拦截器放过

边栏推荐
- What kind of automated test is used for H5 mobile terminal
- 生成所有可能的二叉搜索树
- Chrome plug-in features and case analysis of actual combat scenarios
- What are the good solutions for industrial control safety of production line
- Idea automatically generates unit tests, doubling efficiency!
- Wechat applet picture verification code display
- The lower left corner of vs QT VTK displays the synchronized minor coordinate axis
- [proteus simulation] example of T6963C driving pg12864 (with Chinese and English display)
- High imitation Betta app
- 复原IP地址[标准回溯+标准剪枝]
猜你喜欢

How to ensure reliable power supply of Expressway

smart-doc + Torna 兼容版本

文言文能编程???

Six necessary open source projects for private activities

2018/gan:self attention generating adversarial networks

Idea automatically generates unit tests, doubling efficiency!

6 大完整开源项目,一次学个够

Three cool and coquettish bottom navigation

为实现“双碳”目标,应如何实现节能、合理的照明管控

再来一个高仿开眼的短视频APP
随机推荐
Smart doc + Torna compatible version
《德阳市餐饮服务业油烟污染防治管理办法(征求意见稿)》之创新油烟监管
Innovative lampblack supervision in the management measures for the prevention and control of lampblack pollution in Deyang catering service industry (Draft for comments)
医疗是什么?AI医疗概念解析AI
List<? extends T>和List<?super T>区别
Improvement of DC power distribution with open hall current sensor
文言文能编程???
Notepad++实用功能分享(正则行尾行首替换常用方法、文本比对功能等)
Goodbye, 2020, this bowl of poisonous chicken soup, I'll dry it first
Leetcode——链表笔试题
老龄化下背景下,综合能效管理平台为医院保驾护航
Don't miss | Huawei's internal data - Successful Project Management PPT (page 123)
图扑软件智慧风电:数字孪生 3D 风机智能设备运维
[proteus simulation] example of T6963C driving pg12864 (with Chinese and English display)
C语言c89(c90)的所有的32个关键字分类
MySQL导致索引失效的情况详解
Golang type assertion
[bug] the element in C iqueryable cannot change its value
Facebook 开源微光效果 Shimmer
Complete open source project poetry bar app