Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
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
Administrator
browser-backend
Commits
7c97d381
Commit
7c97d381
authored
Apr 29, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改密码
parent
4fc14970
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
8 deletions
+24
-8
UserController.java
.../edgec/browserbackend/auth/controller/UserController.java
+15
-2
UserAuthServiceImpl.java
...browserbackend/auth/service/Impl/UserAuthServiceImpl.java
+4
-4
UserAuthService.java
...om/edgec/browserbackend/auth/service/UserAuthService.java
+1
-1
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+4
-1
No files found.
src/main/java/com/edgec/browserbackend/auth/controller/UserController.java
View file @
7c97d381
package
com
.
edgec
.
browserbackend
.
auth
.
controller
;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.auth.domain.User
;
import
com.edgec.browserbackend.auth.domain.UserPasswordReset
;
import
com.edgec.browserbackend.auth.service.UserAuthService
;
...
...
@@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.Valid
;
import
java.security.Principal
;
import
java.util.HashMap
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/auth"
)
...
...
@@ -95,8 +98,18 @@ public class UserController {
}
@RequestMapping
(
path
=
"/changepass"
,
method
=
RequestMethod
.
PUT
)
public
void
changePassword
(
@Valid
@RequestBody
UserPasswordReset
userPasswordReset
)
{
userAuthService
.
changePassword
(
userPasswordReset
);
public
ResultDto
changePassword
(
@Valid
@RequestBody
UserPasswordReset
userPasswordReset
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
resultDto
.
setData
(
userAuthService
.
changePassword
(
userPasswordReset
));
resultDto
.
setStatus
(
0
);
}
catch
(
Exception
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
return
resultDto
;
}
...
...
src/main/java/com/edgec/browserbackend/auth/service/Impl/UserAuthServiceImpl.java
View file @
7c97d381
...
...
@@ -121,7 +121,7 @@ public class UserAuthServiceImpl implements UserAuthService {
}
@Override
public
void
changePassword
(
UserPasswordReset
userPasswordReset
)
{
public
boolean
changePassword
(
UserPasswordReset
userPasswordReset
)
{
User
existing
=
repository
.
findById
(
userPasswordReset
.
getUsername
()).
orElseThrow
(()
->
new
ClientRequestException
(
AuthErrorCode
.
NAMENOTEXIST
,
"user does not exist: "
+
userPasswordReset
.
getUsername
()));
if
(!
StringUtils
.
isEmpty
(
userPasswordReset
.
getPassword
()))
{
//change password with old password
...
...
@@ -131,7 +131,7 @@ public class UserAuthServiceImpl implements UserAuthService {
String
newhash
=
encoder
.
encode
(
userPasswordReset
.
getNewPassword
());
existing
.
setPassword
(
newhash
);
repository
.
save
(
existing
);
return
;
return
true
;
}
else
{
throw
new
ClientRequestException
(
AuthErrorCode
.
AUTHENTICATION_ERROR
,
"Wrong password used."
);
}
...
...
@@ -143,12 +143,12 @@ public class UserAuthServiceImpl implements UserAuthService {
existing
.
setPassword
(
newhash
);
existing
.
setVerificationCode
(
""
);
repository
.
save
(
existing
);
return
;
return
true
;
}
else
{
throw
new
ClientRequestException
(
AuthErrorCode
.
AUTHENTICATION_ERROR
,
"Wrong verification code."
);
}
}
throw
new
ClientRequestException
(
AuthErrorCode
.
OTHERS
,
"Wrong password change request."
)
;
return
false
;
}
...
...
src/main/java/com/edgec/browserbackend/auth/service/UserAuthService.java
View file @
7c97d381
...
...
@@ -16,7 +16,7 @@ public interface UserAuthService {
void
unlock
(
User
user
,
String
unlock
);
void
changePassword
(
UserPasswordReset
userPasswordReset
);
boolean
changePassword
(
UserPasswordReset
userPasswordReset
);
void
deleteUser
(
String
name
);
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
7c97d381
...
...
@@ -210,6 +210,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusWeeks
(
ipResourceRequestDto
.
getPeriod
()).
toInstant
().
toEpochMilli
());
else
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusMonths
(
ipResourceRequestDto
.
getPeriod
()).
toInstant
().
toEpochMilli
());
ipResource
.
setPort
(
port
);
}
else
if
(
ipResourceRequestDto
.
getVendor
().
equals
(
"own"
))
{
if
(
ipResourceRequestDto
.
getAddr
()
==
null
||
ipResourceRequestDto
.
getAddr
().
size
()
==
0
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
...
...
@@ -220,6 +221,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResource
.
setStatus
(
4
);
ipResource
.
setUsername
(
ipResourceRequestDto
.
getUsername
());
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
toInstant
().
toEpochMilli
());
ipResource
.
setPort
(
ipResourceRequestDto
.
getPorts
());
}
else
{
ipResource
.
setAddr
(
""
);
ipResource
.
setIpType
(
IpType
.
VENDOR
);
...
...
@@ -238,9 +240,10 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResource
.
setStatus
(
6
);
ipResource
.
setValidTime
(
Instant
.
now
().
plusSeconds
(
3600
*
24
*
30
).
toEpochMilli
());
ipResource
.
setUsername
(
USERNAME
);
ipResource
.
setPort
(
port
);
}
ipResource
.
setPurchasedTime
(
Instant
.
now
().
toEpochMilli
());
ipResource
.
setPort
(
port
);
if
(
account
.
getParent
()
!=
null
)
ipResource
.
setUserParent
(
account
.
getParent
());
ipResource
.
setRegion
(
ipResourceRequestDto
.
getRegion
());
...
...
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