Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
sentinel
Commits
4a832442
Commit
4a832442
authored
Oct 10, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化登陆校验,密码加密
parent
2cc4c23b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
41 deletions
+23
-41
MemberOpenApiController.java
...main/java/com/egolm/film/api/MemberOpenApiController.java
+4
-3
MemberService.java
...java/com/egolm/film/api/member/service/MemberService.java
+1
-1
MemberServiceImpl.java
...egolm/film/api/member/service/impl/MemberServiceImpl.java
+1
-1
MemberTokenServiceImpl.java
...egolm/film/login/service/impl/MemberTokenServiceImpl.java
+17
-36
No files found.
src/main/java/com/egolm/film/api/MemberOpenApiController.java
View file @
4a832442
...
...
@@ -71,11 +71,12 @@ public class MemberOpenApiController {
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"string"
,
required
=
true
,
name
=
"email"
)})
public
Object
getPassword
(
String
email
)
{
int
code
=
(
int
)
((
Math
.
random
()
*
9
+
1
)
*
10000000
);
String
newP
assword
=
String
.
valueOf
(
code
);
String
p
assword
=
String
.
valueOf
(
code
);
Fc_member
member
=
memberService
.
getMemberByEmail
(
email
);
memberService
.
changePassword
(
member
.
getAddress
(),
newPassword
);
String
encodePwd
=
memberService
.
encodePassword
(
member
.
getSalt
(),
password
);
memberService
.
changePassword
(
member
.
getId
(),
encodePwd
);
String
subject
=
messages
.
get
(
"email.getPassword.subject"
);
String
content
=
messages
.
get
(
"email.getPassword.subject"
,
member
.
getRealname
(),
newP
assword
);
String
content
=
messages
.
get
(
"email.getPassword.subject"
,
member
.
getRealname
(),
p
assword
);
emailService
.
send
(
subject
,
content
,
email
);
return
Rjx
.
jsonOk
();
}
...
...
src/main/java/com/egolm/film/api/member/service/MemberService.java
View file @
4a832442
...
...
@@ -11,7 +11,7 @@ public interface MemberService {
Fc_member
getMemberByEmail
(
String
email
);
void
changePassword
(
String
id
,
String
newPassword
);
void
changePassword
(
Integer
id
,
String
newPassword
);
void
saveMember
(
Fc_member
member
);
...
...
src/main/java/com/egolm/film/api/member/service/impl/MemberServiceImpl.java
View file @
4a832442
...
...
@@ -19,7 +19,7 @@ public class MemberServiceImpl implements MemberService {
private
JdbcTemplate
jdbcTemplate
;
@Override
public
void
changePassword
(
String
id
,
String
newPassword
)
{
public
void
changePassword
(
Integer
id
,
String
newPassword
)
{
String
sql
=
"update fc_member set password = ? where id = ?"
;
jdbcTemplate
.
executeUpdate
(
sql
,
newPassword
,
id
);
}
...
...
src/main/java/com/egolm/film/login/service/impl/MemberTokenServiceImpl.java
View file @
4a832442
package
com
.
egolm
.
film
.
login
.
service
.
impl
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpSession
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.film.api.member.service.MemberService
;
import
com.egolm.film.bean.Fc_member
;
import
com.egolm.film.common.Messages
;
import
com.egolm.film.config.WebMvcConfig
;
import
com.egolm.film.config.XException
;
...
...
@@ -23,27 +19,20 @@ public class MemberTokenServiceImpl implements MemberTokenService {
@Autowired
private
Messages
messages
;
@Autowired
private
JdbcTemplate
jdbcTemplate
;
@Autowired
private
MemberService
memberService
;
@Override
public
LoginToken
doLogin
(
String
username
,
String
password
)
{
public
LoginToken
doLogin
(
String
email
,
String
password
)
{
HttpSession
session
=
WebMvcConfig
.
getSession
();
String
loginSql
=
"select * from fc_member where email = ?"
;
List
<
Map
<
String
,
Object
>>
list
=
this
.
jdbcTemplate
.
queryForList
(
loginSql
,
username
);
if
(
list
!=
null
)
{
if
(
list
.
size
()
==
1
)
{
Map
<
String
,
Object
>
map
=
list
.
get
(
0
);
Integer
state
=
(
Integer
)
map
.
get
(
"state"
);
Fc_member
member
=
memberService
.
getMemberByEmail
(
email
);
Integer
state
=
member
.
getState
();
if
(
state
==
1
)
{
String
salt
=
(
String
)
map
.
get
(
"salt"
);
String
dbPwd
=
(
String
)
map
.
get
(
"password"
);
String
salt
=
member
.
getSalt
(
);
String
dbPwd
=
member
.
getPassword
(
);
String
encodePassword
=
memberService
.
encodePassword
(
salt
,
password
);
if
(
encodePassword
.
equals
(
dbPwd
))
{
Integer
id
=
(
Integer
)
map
.
get
(
"id"
);
Integer
id
=
member
.
getId
(
);
LoginToken
token
=
new
LoginToken
(
id
);
session
.
setAttribute
(
TOKEN_NAME
,
token
);
return
token
;
...
...
@@ -55,14 +44,6 @@ public class MemberTokenServiceImpl implements MemberTokenService {
}
else
{
throw
new
XException
(
messages
.
get
(
"sys.err"
));
}
}
else
if
(
list
.
size
()
==
0
)
{
throw
new
XException
(
messages
.
get
(
"sys.err.user_pwd_err"
));
}
else
{
throw
new
XException
(
messages
.
get
(
"sys.err"
));
}
}
else
{
throw
new
XException
(
messages
.
get
(
"sys.err.user_pwd_err"
));
}
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment