Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
御承扬
Campus
提交
eabe83f1
C
Campus
项目概览
御承扬
/
Campus
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Campus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
eabe83f1
编写于
1月 31, 2021
作者:
7
7wc98#14
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit
上级
c7d6feb0
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
47 addition
and
9 deletion
+47
-9
pom.xml
pom.xml
+9
-0
src/main/java/com/pyc/campus/chat/ChatController.java
src/main/java/com/pyc/campus/chat/ChatController.java
+4
-1
src/main/java/com/pyc/campus/config/WebSecurityConfig.java
src/main/java/com/pyc/campus/config/WebSecurityConfig.java
+4
-1
src/main/java/com/pyc/campus/controller/FriendListController.java
.../java/com/pyc/campus/controller/FriendListController.java
+3
-1
src/main/resources/static/js/jquery.min.js
src/main/resources/static/js/jquery.min.js
+2
-0
src/main/resources/templates/page/Login.html
src/main/resources/templates/page/Login.html
+12
-3
src/main/resources/templates/page/Sign.html
src/main/resources/templates/page/Sign.html
+13
-3
未找到文件。
pom.xml
浏览文件 @
eabe83f1
...
...
@@ -19,6 +19,15 @@
<java.version>
1.8
</java.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
<!--文件上传依赖-->
<dependency>
<groupId>
commons-fileupload
</groupId>
...
...
src/main/java/com/pyc/campus/c
ontroller
/ChatController.java
→
src/main/java/com/pyc/campus/c
hat
/ChatController.java
浏览文件 @
eabe83f1
...
...
@@ -5,12 +5,13 @@
// Author:御承扬
//E-mail:2923616405@qq.com
package
com.pyc.campus.c
ontroller
;
package
com.pyc.campus.c
hat
;
import
com.pyc.campus.dao.StudentRepository
;
import
com.pyc.campus.domain.PublishMessage
;
import
com.pyc.campus.domain.ResponseMessage
;
import
com.pyc.campus.domain.Student
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.messaging.handler.annotation.DestinationVariable
;
import
org.springframework.messaging.handler.annotation.MessageMapping
;
...
...
@@ -25,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
javax.servlet.http.HttpSession
;
import
java.security.Principal
;
@Slf4j
@Controller
public
class
ChatController
{
...
...
@@ -36,6 +38,7 @@ public class ChatController {
@RequestMapping
(
"/publicChatRoom"
)
public
String
publicChatRoom
(
Model
model
,
HttpSession
session
){
log
.
info
(
"由用户进入公共聊天室...."
);
SecurityContextImpl
securityContext
=
(
SecurityContextImpl
)
session
.
getAttribute
(
"SPRING_SECURITY_CONTEXT"
);
String
currentStudentId
=
((
UserDetails
)
securityContext
.
getAuthentication
().
getPrincipal
()).
getUsername
();
Student
s
=
studentRepository
.
findNameByStudentID
(
currentStudentId
);
...
...
src/main/java/com/pyc/campus/config/WebSecurityConfig.java
浏览文件 @
eabe83f1
...
...
@@ -12,12 +12,13 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.
builders.
WebSecurity
;
import
org.springframework.security.config.annotation.web.
configuration.Enable
WebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.crypto.password.NoOpPasswordEncoder
;
@Configuration
@EnableWebSecurity
public
class
WebSecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Bean
UserDetailsService
customUserService
(){
...
...
@@ -48,6 +49,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/static/**"
).
permitAll
()
.
antMatchers
(
"/static/**/**"
).
permitAll
()
.
antMatchers
(
"/static/**/**/**"
).
permitAll
()
.
antMatchers
(
"/static/**/**.**"
).
permitAll
()
.
antMatchers
(
"/static/**/**.**.**"
).
permitAll
()
.
antMatchers
(
"/images/**/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
.
and
().
formLogin
()
...
...
src/main/java/com/pyc/campus/controller/FriendListController.java
浏览文件 @
eabe83f1
...
...
@@ -5,6 +5,7 @@ import com.pyc.campus.dao.StudentRepository;
import
com.pyc.campus.domain.FriendList
;
import
com.pyc.campus.domain.Msg
;
import
com.pyc.campus.domain.Student
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.security.core.context.SecurityContextImpl
;
import
org.springframework.security.core.userdetails.UserDetails
;
...
...
@@ -25,7 +26,7 @@ import java.util.List;
* @time 11:44
* @E-mail 2923616405@qq.com
**/
@Slf4j
@Controller
public
class
FriendListController
{
...
...
@@ -118,6 +119,7 @@ public class FriendListController {
SecurityContextImpl
securityContext
=
(
SecurityContextImpl
)
session
.
getAttribute
(
"SPRING_SECURITY_CONTEXT"
);
String
currentStudentId
=
((
UserDetails
)
securityContext
.
getAuthentication
().
getPrincipal
()).
getUsername
();
log
.
info
(
currentStudentId
+
"发起与"
+
toName
+
"的私聊...."
);
Student
toUse
=
studentRepository
.
findNameByStudentID
(
toName
);
model
.
addAttribute
(
"curUser"
,
toUse
);
boolean
s
;
...
...
src/main/resources/static/js/jquery.min.js
0 → 100644
浏览文件 @
eabe83f1
此差异已折叠。
点击以展开。
src/main/resources/templates/page/Login.html
浏览文件 @
eabe83f1
...
...
@@ -27,7 +27,7 @@
</div>-->
<h1>
登陆
</h1>
<form
class=
"form-horizontal"
name=
"form"
id=
"form"
method=
"post"
th:action=
"@{/login}"
action=
"/login"
onsubmit=
"return checkPWD(form.password,form.checkPassword)"
>
action=
"/login"
onsubmit=
"return checkPWD(form.password,form.checkPassword
,form.username
)"
>
<div
class=
"input-group input-group-lg"
>
<span
class=
"input-group-addon"
id=
"sizing-addon1"
>
@
</span>
<input
type=
"text"
name=
"username"
class=
"form-control"
placeholder=
"studentID"
aria-describedby=
"sizing-addon1"
>
...
...
@@ -50,8 +50,17 @@
</form>
</div>
<script>
function
checkPWD
(
password
,
checkPassword
)
{
if
(
password
.
value
!==
checkPassword
.
value
){
function
checkPWD
(
password
,
checkPassword
,
stuID
)
{
if
(
stuID
.
value
===
""
){
alert
(
"
学号不得为空
"
);
return
false
;
}
else
if
(
password
===
""
){
alert
(
"
密码不得为空
"
);
return
false
;
}
else
if
(
password
.
value
!==
checkPassword
.
value
){
alert
(
"
密码不一致
"
);
return
false
;
}
else
{
...
...
src/main/resources/templates/page/Sign.html
浏览文件 @
eabe83f1
...
...
@@ -25,7 +25,8 @@
<h1
th:text=
"${msg.title}"
></h1>
<p
class=
"bg-primary"
th:text=
"${msg.content}"
></p>
</div>
<form
class=
"form-horizontal"
name=
"form"
action=
"/signUP"
onsubmit=
"return checkPWD(form.password,form.checkPassword)"
>
<form
class=
"form-horizontal"
name=
"form"
action=
"/signUP"
onsubmit=
"return checkPWD(form.password,form.checkPassword,form.studentID)"
>
<div
class=
"input-group input-group-lg"
>
<span
class=
"input-group-addon"
id=
"sizing-addon1"
>
@
</span>
<input
type=
"text"
name=
"studentID"
class=
"form-control"
placeholder=
"studentID"
aria-describedby=
"sizing-addon1"
>
...
...
@@ -58,8 +59,17 @@
</form>
</div>
<script>
function
checkPWD
(
password
,
checkPassword
)
{
if
(
password
.
value
!==
checkPassword
.
value
){
function
checkPWD
(
password
,
checkPassword
,
stuID
)
{
if
(
stuID
.
value
===
""
){
alert
(
"
学号不得为空
"
);
return
false
;
}
else
if
(
password
===
""
){
alert
(
"
密码不得为空
"
);
return
false
;
}
else
if
(
password
.
value
!==
checkPassword
.
value
){
alert
(
"
密码不一致
"
);
return
false
;
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录