Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
onionZunyi
beauty_ssm
提交
54bc8ca7
B
beauty_ssm
项目概览
onionZunyi
/
beauty_ssm
与 Fork 源项目一致
Fork自
爱吃血肠 / beauty_ssm
通知
6
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
beauty_ssm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
54bc8ca7
编写于
3月 25, 2018
作者:
爱吃血肠
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
找回密码模块完成
上级
b8089610
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
99 addition
and
19 deletion
+99
-19
src/main/java/com/yingjun/ssm/service/UserService.java
src/main/java/com/yingjun/ssm/service/UserService.java
+8
-0
src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java
...in/java/com/yingjun/ssm/service/impl/UserServiceImpl.java
+35
-0
src/main/java/com/yingjun/ssm/web/FindPwdController.java
src/main/java/com/yingjun/ssm/web/FindPwdController.java
+5
-3
src/main/webapp/WEB-INF/jsp/user/findPwd.jsp
src/main/webapp/WEB-INF/jsp/user/findPwd.jsp
+6
-4
src/main/webapp/resource/script/findPwd.js
src/main/webapp/resource/script/findPwd.js
+45
-12
未找到文件。
src/main/java/com/yingjun/ssm/service/UserService.java
浏览文件 @
54bc8ca7
...
...
@@ -88,4 +88,12 @@ public interface UserService {
* @return
*/
public
User
queryUserByEmail
(
String
email
);
/**
* 根据邮箱修改用户密码
* @param user 用户信息
* @param code 验证码
* @param session 存储系统发送的验证码
*/
public
void
updatePasswordByEmail
(
User
user
,
String
code
,
HttpSession
session
);
}
\ No newline at end of file
src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java
浏览文件 @
54bc8ca7
...
...
@@ -139,4 +139,39 @@ public class UserServiceImpl implements UserService {
return
userDao
.
queryUserByEmail
(
email
);
}
/**
* 根据邮箱修改当前登录用户的密码
* @param user 用户信息
* @param code 验证码
* @param session session存储系统发送的验证码
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
READ_COMMITTED
,
rollbackFor
=
Throwable
.
class
)
@Override
public
void
updatePasswordByEmail
(
User
user
,
String
code
,
HttpSession
session
)
{
try
{
User
userFind
=
queryUserByEmail
(
user
.
getEmail
());
if
(
userFind
==
null
){
throw
new
BizException
(
"用户不存在"
);
}
String
emailCode
=
(
String
)
session
.
getAttribute
(
"code"
);
if
(!
emailCode
.
equals
(
code
)){
throw
new
BizException
(
"验证码错误"
);
}
//加密密码
if
(
user
!=
null
){
user
.
setPassword
(
Md5Util
.
md5Password
(
user
.
getPassword
()));
}
else
{
return
;
}
user
.
setId
(
userFind
.
getId
());
if
(
1
!=
userDao
.
updateTUserById
(
user
)){
throw
new
Exception
(
"插入数据影响函数不唯一"
);
}
}
catch
(
BizException
biz
){
throw
new
BizException
(
biz
.
getMessage
(),
biz
);
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
"插入数据影响函数不唯一"
,
e
);
}
}
}
\ No newline at end of file
src/main/java/com/yingjun/ssm/web/FindPwdController.java
浏览文件 @
54bc8ca7
...
...
@@ -47,14 +47,16 @@ public class FindPwdController {
*/
@ResponseBody
@RequestMapping
(
value
=
"/findPwd"
,
produces
=
{
"application/json;charset=UTF-8"
})
public
BaseResult
<
Object
>
userLogin
()
{
public
BaseResult
<
Object
>
userLogin
(
User
user
,
String
code
,
HttpSession
session
)
{
try
{
LOG
.
info
(
"用户信息 "
+
user
);
LOG
.
info
(
"用户输入的验证码 "
+
code
);
userService
.
updatePasswordByEmail
(
user
,
code
,
session
);
}
catch
(
BizException
e
)
{
return
new
BaseResult
<>(
false
,
e
.
getMessage
());
}
catch
(
Exception
e
)
{
return
new
BaseResult
<>(
false
,
ResultEnum
.
INVALID_USER
.
getMsg
());
}
return
new
BaseResult
<>(
true
,
"
登陆
成功"
);
return
new
BaseResult
<>(
true
,
"
修改
成功"
);
}
}
src/main/webapp/WEB-INF/jsp/user/findPwd.jsp
浏览文件 @
54bc8ca7
...
...
@@ -45,19 +45,20 @@
</div>
<div
class=
"findPwd"
>
<div
class=
"contentInfo"
>
<form
action=
"/find/findPwd"
id=
"findPwdForm"
name=
"findPwdForm"
>
<ul
class=
"getInfo margin-t-49 margin-l-40"
>
<li
class=
"margin-b-19"
>
<label
class=
"infoName1 inputDes"
for=
"
te
l"
>
登录邮箱号:
</label>
<input
class=
"info2"
type=
"text"
name=
"email"
id=
"
te
l"
value=
""
placeholder=
""
/>
<label
class=
"infoName1 inputDes"
for=
"
emai
l"
>
登录邮箱号:
</label>
<input
class=
"info2"
type=
"text"
name=
"email"
id=
"
emai
l"
value=
""
placeholder=
""
/>
</li>
<li
class=
"margin-b-19"
>
<label
class=
"infoName1 inputDes"
for=
"code"
>
验证码:
</label>
<input
class=
"info2"
type=
"text"
name=
"code"
id=
"code"
value=
""
placeholder=
""
/>
<span
class=
"bounceBtn"
id=
"getCode"
onclick=
"set
t
ime(this)"
><a
class=
"count"
href=
"javascript:void(0)"
>
获取验证码
</a></span>
<span
class=
"bounceBtn"
id=
"getCode"
onclick=
"set
T
ime(this)"
><a
class=
"count"
href=
"javascript:void(0)"
>
获取验证码
</a></span>
</li>
<li
class=
"margin-b-19"
>
<label
class=
"infoName1 inputDes"
for=
"newPwd"
>
新登录密码:
</label>
<input
class=
"info write-n"
type=
"text"
name=
"
newPw
d"
id=
"newPwd"
value=
""
placeholder=
""
/>
<input
class=
"info write-n"
type=
"text"
name=
"
passwor
d"
id=
"newPwd"
value=
""
placeholder=
""
/>
</li>
<li
class=
"margin-b-19"
>
<label
class=
"infoName1 inputDes"
for=
"pwd-a"
>
再次输入新密码:
</label>
...
...
@@ -67,6 +68,7 @@
<div
class=
"btn-bounce"
onclick=
"sure()"
>
<a
class=
"width-206"
href=
"javascript:void(0)"
>
确定
</a>
</div>
</form>
</div>
</div>
</div>
...
...
src/main/webapp/resource/script/findPwd.js
浏览文件 @
54bc8ca7
...
...
@@ -42,25 +42,43 @@ function addReceive(){
function
closeBounce
(){
$
(
"
.bounces
"
).
addClass
(
'
hide
'
);
}
function
settime
(
val
)
{
// 获取验证码
var
countdown
=
60
;
function
setTime
(
val
)
{
var
$val
=
$
(
val
);
if
(
countdown
==
0
)
{
if
(
countdown
==
60
){
//异步发送验证码
$
.
ajax
({
type
:
'
POST
'
,
data
:
$
(
'
#findPwdForm
'
).
serialize
(),
dataType
:
"
json
"
,
url
:
'
/user/getEmailCode
'
,
success
:
function
(
data
)
{
if
(
data
.
success
)
{
}
else
{
}
}
});
}
if
(
countdown
==
0
)
{
$
(
'
#getCode
'
).
removeClass
(
'
countBtn
'
);
$
(
'
#getCode
'
).
addClass
(
'
bounceBtn
'
);
val
.
removeAttribute
(
"
disabled
"
);
val
.
removeAttribute
(
"
disabled
"
);
$val
.
children
().
html
(
"
获取验证码
"
)
countdown
=
60
;
}
else
{
countdown
=
60
;
}
else
{
$
(
'
#getCode
'
).
removeClass
(
'
bounceBtn
'
);
$
(
'
#getCode
'
).
addClass
(
'
countBtn
'
);
val
.
setAttribute
(
"
disabled
"
,
true
);
val
.
setAttribute
(
"
disabled
"
,
true
);
$val
.
children
().
html
(
"
重新发送
"
+
countdown
+
"
s
"
)
countdown
--
;
setTimeout
(
function
()
{
settime
(
val
)
},
1000
)
}
}
countdown
--
;
setTimeout
(
function
()
{
settime
(
val
)
},
1000
)
}
}
function
sure
(){
var
$newPwd
=
$
(
"
#newPwd
"
).
val
();
var
$pwda
=
$
(
"
#pwd-a
"
).
val
();
...
...
@@ -69,4 +87,19 @@ function sure(){
$
(
"
#pwd-a
"
).
addClass
(
'
noPass
'
)
$
(
"
#pwd-a
"
).
after
(
'
<span class="noPassImg-bounce"><img src="img/refuse.png"/>输入不一致</span>
'
)
}
$
.
ajax
({
type
:
'
POST
'
,
data
:
$
(
'
#findPwdForm
'
).
serialize
(),
dataType
:
"
json
"
,
url
:
'
/find/findPwd
'
,
success
:
function
(
data
)
{
if
(
data
.
success
){
alert
(
"
修改成功
"
);
window
.
location
.
href
=
"
/user/login
"
;
}
else
{
alert
(
data
.
error
);
}
}
});
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录