Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
notes2.0
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zjm
notes2.0
Commits
d96b3d28
提交
d96b3d28
authored
3月 11, 2020
作者:
gongwenjie
浏览文件
操作
浏览文件
下载
差异文件
合并分支 'gwj' 到 'master'
Gwj 查看合并请求
!47
上级
64302d91
1b66c46e
流水线
#68
已取消 于阶段
变更
9
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
62 行增加
和
27 行删除
+62
-27
CorsConfig.java
...src/main/java/com/zjty/tynotes/pas/config/CorsConfig.java
+30
-0
MyUserDetailsServiceImpl.java
...com/zjty/tynotes/pas/config/MyUserDetailsServiceImpl.java
+1
-1
MySuccessHandler.java
...com/zjty/tynotes/pas/config/handler/MySuccessHandler.java
+2
-10
UserController.java
.../java/com/zjty/tynotes/pas/controller/UserController.java
+11
-0
UserServiceImpl.java
...va/com/zjty/tynotes/pas/service/impl/UserServiceImpl.java
+3
-3
Init.java
notes-pas/src/main/java/com/zjty/tynotes/pas/task/Init.java
+3
-2
UnionApplication.java
...rc/main/java/com/zjty/tynotes/union/UnionApplication.java
+9
-9
application.properties
notes-union/src/main/resources/application.properties
+1
-1
UserManageServiceImpl.java
...es/weekly/subject/service/impl/UserManageServiceImpl.java
+2
-1
没有找到文件。
notes-pas/src/main/java/com/zjty/tynotes/pas/config/CorsConfig.java
0 → 100644
浏览文件 @
d96b3d28
package
com
.
zjty
.
tynotes
.
pas
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.CorsConfigurationSource
;
import
org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.filter.CorsFilter
;
/**
* @Author gwj
* @create 2020/3/11 10:37
*/
@Configuration
public
class
CorsConfig
{
private
CorsConfiguration
buildConfig
()
{
CorsConfiguration
corsConfiguration
=
new
CorsConfiguration
();
corsConfiguration
.
addAllowedOrigin
(
"*"
);
//允许任何域名
corsConfiguration
.
addAllowedHeader
(
"*"
);
//允许任何头
corsConfiguration
.
addAllowedMethod
(
"*"
);
//允许任何方法
return
corsConfiguration
;
}
@Bean
public
CorsFilter
corsFilter
()
{
UrlBasedCorsConfigurationSource
source
=
new
UrlBasedCorsConfigurationSource
();
source
.
registerCorsConfiguration
(
"/**"
,
buildConfig
());
//注册
return
new
CorsFilter
((
CorsConfigurationSource
)
source
);
}
}
notes-pas/src/main/java/com/zjty/tynotes/pas/config/MyUserDetailsServiceImpl.java
浏览文件 @
d96b3d28
...
...
@@ -54,7 +54,7 @@ public class MyUserDetailsServiceImpl implements UserDetailsService {
if
(
username
.
equals
(
"root"
)){
User
root
=
init
.
root
;
// root.setPassword("root");
root
.
setPassword
(
bCryptPasswordEncoder
.
encode
(
"root"
));
//
root.setPassword(bCryptPasswordEncoder.encode("root"));
List
<
SimpleGrantedAuthority
>
authorityList
=
new
ArrayList
<>();
List
<
Role
>
roles
=
root
.
getRoles
();
Role
role
=
roles
.
get
(
0
);
...
...
notes-pas/src/main/java/com/zjty/tynotes/pas/config/handler/MySuccessHandler.java
浏览文件 @
d96b3d28
...
...
@@ -82,8 +82,8 @@ public class MySuccessHandler implements AuthenticationSuccessHandler {
String
value
=
cookies
[
0
].
getValue
();
List
<
Object
>
o
=
sessionRegistry
.
getAllPrincipals
();
User
user
=
(
User
)
authentication
.
getPrincipal
();
String
encode
=
bCryptPasswordEncoder
.
encode
(
user
.
getPassword
());
user
.
setPassword
(
encode
);
//
String encode = bCryptPasswordEncoder.encode(user.getPassword());
//
user.setPassword(encode);
for
(
Object
principal
:
o
)
{
User
cacheUser
=
(
User
)
principal
;
if
(
cacheUser
.
getUsername
().
equals
(
user
.
getUsername
()))
{
...
...
@@ -128,12 +128,4 @@ public class MySuccessHandler implements AuthenticationSuccessHandler {
httpServletResponse
.
getWriter
().
println
(
new
ObjectMapper
().
writeValueAsString
(
user
));
}
public
static
void
main
(
String
[]
args
)
{
String
s
=
"qwer1234"
;
BCryptPasswordEncoder
bCryptPasswordEncoder
=
new
BCryptPasswordEncoder
();
String
encode
=
bCryptPasswordEncoder
.
encode
(
s
);
System
.
out
.
println
(
encode
);
String
encode1
=
bCryptPasswordEncoder
.
encode
(
encode
);
System
.
out
.
println
(
encode1
);
}
}
notes-pas/src/main/java/com/zjty/tynotes/pas/controller/UserController.java
浏览文件 @
d96b3d28
...
...
@@ -73,6 +73,17 @@ public class UserController {
}
// @ApiOperation(value = "判断当前密码是否一致")
// @PutMapping("/judgePassword")
// public ResponseEntity updateSelf(@RequestBody @NotNull UserDTO user){
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// User principal = (User) authentication.getPrincipal();
// User userByUsername = iUserService.findUserByUsername(principal.getUsername());
// userByUsername.setPassword(user.getPassword());
// return ok(iUserService.updateUser(userByUsername));
// }
// @ApiOperation(value = "更新当前用户密码")
// @PutMapping("/password")
// public ResponseEntity updateSelf(@RequestBody @NotNull UserDTO user){
...
...
notes-pas/src/main/java/com/zjty/tynotes/pas/service/impl/UserServiceImpl.java
浏览文件 @
d96b3d28
...
...
@@ -218,9 +218,9 @@ public class UserServiceImpl implements IUserService {
@Override
public
User
addUser
(
User
user
)
{
//
String encode = bCryptPasswordEncoder.encode("qwer1234");
//
user.setPassword(encode);
user
.
setPassword
(
"qwer1234"
);
String
encode
=
bCryptPasswordEncoder
.
encode
(
"qwer1234"
);
user
.
setPassword
(
encode
);
//
user.setPassword("qwer1234");
List
<
Role
>
roles
=
user
.
getRoles
();
List
<
UserRole
>
userRoles
=
new
ArrayList
<>();
List
<
User
>
users
=
pasUserDao
.
findAll
();
...
...
notes-pas/src/main/java/com/zjty/tynotes/pas/task/Init.java
浏览文件 @
d96b3d28
...
...
@@ -120,7 +120,8 @@ public class Init implements CommandLineRunner {
this
.
root
.
createUser
();
this
.
root
.
setUsername
(
"root"
);
root
.
setPassword
(
"root"
);
String
encode
=
bCryptPasswordEncoder
.
encode
(
"root"
);
this
.
root
.
setPassword
(
encode
);
List
<
Role
>
roles
=
new
ArrayList
<>();
roles
.
add
(
role
);
this
.
root
.
setRoles
(
roles
);
...
...
@@ -138,7 +139,7 @@ public class Init implements CommandLineRunner {
UserRole
userRole
=
new
UserRole
(
null
,
save
.
getId
(),
id
);
userRoleDao
.
save
(
userRole
);
this
.
root
.
setPassword
(
bCryptPasswordEncoder
.
encode
(
root
.
getPassword
())
);
// this.root.setPassword("root"
);
}
;
...
...
notes-union/src/main/java/com/zjty/tynotes/union/UnionApplication.java
浏览文件 @
d96b3d28
...
...
@@ -35,14 +35,14 @@ public class UnionApplication {
return
tomcat
;
}
private
Connector
createHTTPConnector
()
{
Connector
connector
=
new
Connector
(
"org.apache.coyote.http11.Http11NioProtocol"
);
//同时启用http(8080)、https(8443)两个端口
connector
.
setScheme
(
"http"
);
connector
.
setSecure
(
false
);
connector
.
setPort
(
8084
);
connector
.
setRedirectPort
(
8289
);
return
connector
;
}
private
Connector
createHTTPConnector
()
{
Connector
connector
=
new
Connector
(
"org.apache.coyote.http11.Http11NioProtocol"
);
//同时启用http(8080)、https(8443)两个端口
connector
.
setScheme
(
"http"
);
connector
.
setSecure
(
false
);
connector
.
setPort
(
8084
);
connector
.
setRedirectPort
(
8289
);
return
connector
;
}
}
notes-union/src/main/resources/application.properties
浏览文件 @
d96b3d28
...
...
@@ -14,7 +14,7 @@ server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias
=
alias
#mongodb configuration
spring.data.mongodb.uri
=
mongodb://localhost:27017/
note
spring.data.mongodb.uri
=
mongodb://localhost:27017/
test2
# servlet configuration
spring.servlet.multipart.max-file-size
=
100MB
spring.servlet.multipart.max-request-size
=
1000MB
...
...
notes-weekly/src/main/java/com/zjty/tynotes/weekly/subject/service/impl/UserManageServiceImpl.java
浏览文件 @
d96b3d28
...
...
@@ -236,7 +236,8 @@ public class UserManageServiceImpl implements UserManageService {
@Override
public
boolean
updatePas
(
User
user
)
{
user
.
setPassword
(
user
.
getPassword
());
String
encode
=
bCryptPasswordEncoder
.
encode
(
user
.
getPassword
());
user
.
setPassword
(
encode
);
pasUserDao
.
save
(
user
);
return
true
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论