Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
member-api
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
曲欣亮
member-api
Commits
4a832442
Commit
4a832442
authored
Oct 10, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化登陆校验,密码加密
parent
2cc4c23b
Hide 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 {
...
@@ -71,11 +71,12 @@ public class MemberOpenApiController {
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"string"
,
required
=
true
,
name
=
"email"
)})
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"string"
,
required
=
true
,
name
=
"email"
)})
public
Object
getPassword
(
String
email
)
{
public
Object
getPassword
(
String
email
)
{
int
code
=
(
int
)
((
Math
.
random
()
*
9
+
1
)
*
10000000
);
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
);
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
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
);
emailService
.
send
(
subject
,
content
,
email
);
return
Rjx
.
jsonOk
();
return
Rjx
.
jsonOk
();
}
}
...
...
src/main/java/com/egolm/film/api/member/service/MemberService.java
View file @
4a832442
...
@@ -11,7 +11,7 @@ public interface MemberService {
...
@@ -11,7 +11,7 @@ public interface MemberService {
Fc_member
getMemberByEmail
(
String
email
);
Fc_member
getMemberByEmail
(
String
email
);
void
changePassword
(
String
id
,
String
newPassword
);
void
changePassword
(
Integer
id
,
String
newPassword
);
void
saveMember
(
Fc_member
member
);
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 {
...
@@ -19,7 +19,7 @@ public class MemberServiceImpl implements MemberService {
private
JdbcTemplate
jdbcTemplate
;
private
JdbcTemplate
jdbcTemplate
;
@Override
@Override
public
void
changePassword
(
String
id
,
String
newPassword
)
{
public
void
changePassword
(
Integer
id
,
String
newPassword
)
{
String
sql
=
"update fc_member set password = ? where id = ?"
;
String
sql
=
"update fc_member set password = ? where id = ?"
;
jdbcTemplate
.
executeUpdate
(
sql
,
newPassword
,
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
;
package
com
.
egolm
.
film
.
login
.
service
.
impl
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
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.api.member.service.MemberService
;
import
com.egolm.film.bean.Fc_member
;
import
com.egolm.film.common.Messages
;
import
com.egolm.film.common.Messages
;
import
com.egolm.film.config.WebMvcConfig
;
import
com.egolm.film.config.WebMvcConfig
;
import
com.egolm.film.config.XException
;
import
com.egolm.film.config.XException
;
...
@@ -23,45 +19,30 @@ public class MemberTokenServiceImpl implements MemberTokenService {
...
@@ -23,45 +19,30 @@ public class MemberTokenServiceImpl implements MemberTokenService {
@Autowired
@Autowired
private
Messages
messages
;
private
Messages
messages
;
@Autowired
private
JdbcTemplate
jdbcTemplate
;
@Autowired
@Autowired
private
MemberService
memberService
;
private
MemberService
memberService
;
@Override
@Override
public
LoginToken
doLogin
(
String
username
,
String
password
)
{
public
LoginToken
doLogin
(
String
email
,
String
password
)
{
HttpSession
session
=
WebMvcConfig
.
getSession
();
HttpSession
session
=
WebMvcConfig
.
getSession
();
String
loginSql
=
"select * from fc_member where email = ?"
;
Fc_member
member
=
memberService
.
getMemberByEmail
(
email
);
List
<
Map
<
String
,
Object
>>
list
=
this
.
jdbcTemplate
.
queryForList
(
loginSql
,
username
);
Integer
state
=
member
.
getState
();
if
(
list
!=
null
)
{
if
(
state
==
1
)
{
if
(
list
.
size
()
==
1
)
{
String
salt
=
member
.
getSalt
();
Map
<
String
,
Object
>
map
=
list
.
get
(
0
);
String
dbPwd
=
member
.
getPassword
();
Integer
state
=
(
Integer
)
map
.
get
(
"state"
);
String
encodePassword
=
memberService
.
encodePassword
(
salt
,
password
);
if
(
state
==
1
)
{
if
(
encodePassword
.
equals
(
dbPwd
))
{
String
salt
=
(
String
)
map
.
get
(
"salt"
);
Integer
id
=
member
.
getId
();
String
dbPwd
=
(
String
)
map
.
get
(
"password"
);
LoginToken
token
=
new
LoginToken
(
id
);
String
encodePassword
=
memberService
.
encodePassword
(
salt
,
password
);
session
.
setAttribute
(
TOKEN_NAME
,
token
);
if
(
encodePassword
.
equals
(
dbPwd
))
{
return
token
;
Integer
id
=
(
Integer
)
map
.
get
(
"id"
);
LoginToken
token
=
new
LoginToken
(
id
);
session
.
setAttribute
(
TOKEN_NAME
,
token
);
return
token
;
}
else
{
throw
new
XException
(
messages
.
get
(
"sys.err.user_pwd_err"
));
}
}
else
if
(
state
==
2
)
{
throw
new
XException
(
messages
.
get
(
"sys.err.user_disabled"
));
}
else
{
throw
new
XException
(
messages
.
get
(
"sys.err"
));
}
}
else
if
(
list
.
size
()
==
0
)
{
throw
new
XException
(
messages
.
get
(
"sys.err.user_pwd_err"
));
}
else
{
}
else
{
throw
new
XException
(
messages
.
get
(
"sys.err"
));
throw
new
XException
(
messages
.
get
(
"sys.err
.user_pwd_err
"
));
}
}
}
else
if
(
state
==
2
)
{
throw
new
XException
(
messages
.
get
(
"sys.err.user_disabled"
));
}
else
{
}
else
{
throw
new
XException
(
messages
.
get
(
"sys.err
.user_pwd_err
"
));
throw
new
XException
(
messages
.
get
(
"sys.err"
));
}
}
}
}
...
...
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