Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alvachien
spring-auth-server-demo
提交
b9107f54
S
spring-auth-server-demo
项目概览
alvachien
/
spring-auth-server-demo
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-auth-server-demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b9107f54
编写于
12月 10, 2022
作者:
alvachien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new logic
上级
64b5ef15
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
91 addition
and
42 deletion
+91
-42
auth-server-demo/src/main/java/com/poc/alvachien/authserverdemo/config/SecurityConfig.java
...m/poc/alvachien/authserverdemo/config/SecurityConfig.java
+1
-1
auth-server-demo/src/main/java/com/poc/alvachien/authserverdemo/controller/MainController.java
...c/alvachien/authserverdemo/controller/MainController.java
+19
-1
auth-server-demo/src/main/java/com/poc/alvachien/authserverdemo/model/LoginDto.java
...java/com/poc/alvachien/authserverdemo/model/LoginDto.java
+25
-0
auth-server-demo/src/main/resources/templates/login.html
auth-server-demo/src/main/resources/templates/login.html
+39
-32
auth-server-demo/src/main/resources/templates/register.html
auth-server-demo/src/main/resources/templates/register.html
+7
-8
未找到文件。
auth-server-demo/src/main/java/com/poc/alvachien/authserverdemo/config/SecurityConfig.java
浏览文件 @
b9107f54
...
...
@@ -99,7 +99,7 @@ public class SecurityConfig {
.
formLogin
(
form
->
form
.
loginPage
(
"/login"
)
.
loginProcessingUrl
(
"/login"
)
//
.loginProcessingUrl("/login")
.
defaultSuccessUrl
(
"/user"
)
.
permitAll
()
)
...
...
auth-server-demo/src/main/java/com/poc/alvachien/authserverdemo/controller/MainController.java
浏览文件 @
b9107f54
...
...
@@ -4,13 +4,17 @@ import jakarta.validation.Valid;
import
java.util.List
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
com.poc.alvachien.authserverdemo.model.LoginDto
;
import
com.poc.alvachien.authserverdemo.model.UserAccount
;
import
com.poc.alvachien.authserverdemo.model.UserAccountDto
;
import
com.poc.alvachien.authserverdemo.service.UserService
;
...
...
@@ -36,11 +40,25 @@ public class MainController {
}
@GetMapping
(
"/login"
)
public
String
loginForm
()
{
public
String
loginForm
(
Model
model
)
{
log
.
info
(
"Requiring /login"
);
LoginDto
ld
=
new
LoginDto
();
model
.
addAttribute
(
"login"
,
ld
);
return
"login"
;
}
// @PostMapping("/login")
// public String login(@Valid @ModelAttribute("login") LoginDto loginData,
// BindingResult result, Model model) {
// log.info("Posting to /login");
// //return sysUserService.login(loginBody);
// Authentication authentication = authenticationManager
// .authenticate(new UsernamePasswordAuthenticationToken(loginData.getEmail(), loginData.getPassword()));
// return "user";
// }
// handler method to handle user registration request
@GetMapping
(
"register"
)
public
String
showRegistrationForm
(
Model
model
){
...
...
auth-server-demo/src/main/java/com/poc/alvachien/authserverdemo/model/LoginDto.java
0 → 100644
浏览文件 @
b9107f54
package
com.poc.alvachien.authserverdemo.model
;
import
jakarta.validation.constraints.Email
;
import
jakarta.validation.constraints.NotEmpty
;
public
class
LoginDto
{
@NotEmpty
(
message
=
"Email should not be empty"
)
@Email
private
String
email
;
@NotEmpty
(
message
=
"Password should not be empty"
)
private
String
password
;
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
auth-server-demo/src/main/resources/templates/login.html
浏览文件 @
b9107f54
...
...
@@ -2,44 +2,51 @@
<html
lang=
"en"
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
AC Auth. System
</title>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin=
"anonymous"
>
<link
rel=
"stylesheet"
type=
"text/css"
th:href=
"@{/static/css/login.css}"
/>
<meta
charset=
"UTF-8"
>
<title>
AC Auth. System
</title>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin=
"anonymous"
>
<link
rel=
"stylesheet"
type=
"text/css"
th:href=
"@{/static/css/login.css}"
/>
</head>
<body>
<div
class=
"container py-3"
>
<div
th:replace=
"~{fragments/header :: header}"
>
Header
<div
class=
"container py-3"
>
<div
th:replace=
"~{fragments/header :: header}"
>
Header
</div>
<main
class=
"form-signin w-100 m-auto"
>
<form
method=
"post"
role=
"form"
th:action=
"@{/login}"
th:object=
"${login}"
>
<img
class=
"mb-4"
th:src=
"@{/static/img/logo.svg}"
alt=
""
width=
"72"
height=
"57"
>
<h1
class=
"h3 mb-3 fw-normal"
>
Please sign in
</h1>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
Email
</label>
<input
class=
"form-control"
id=
"email"
name=
"email"
placeholder=
"Enter email address"
th:field=
"*{email}"
type=
"email"
/>
<p
th:errors=
"*{email}"
class=
"text-danger"
th:if=
"${#fields.hasErrors('email')}"
>
</p>
</div>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
Password
</label>
<input
class=
"form-control"
id=
"password"
name=
"password"
placeholder=
"Enter password"
th:field=
"*{password}"
type=
"password"
/>
<p
th:errors=
"*{password}"
class=
"text-danger"
th:if=
"${#fields.hasErrors('password')}"
>
</p>
</div>
<div
class=
"checkbox mb-3"
>
<label>
<input
type=
"checkbox"
value=
"remember-me"
>
Remember me
</label>
</div>
<button
class=
"w-100 btn btn-lg btn-primary"
type=
"submit"
>
Sign in
</button>
</form>
</main>
<main
class=
"form-signin w-100 m-auto"
>
<form>
<img
class=
"mb-4"
th:src=
"@{/static/img/logo.svg}"
alt=
""
width=
"72"
height=
"57"
>
<h1
class=
"h3 mb-3 fw-normal"
>
Please sign in
</h1>
<div
class=
"form-floating"
>
<input
type=
"email"
class=
"form-control"
id=
"floatingInput"
placeholder=
"name@example.com"
>
<label
for=
"floatingInput"
>
Email address
</label>
</div>
<div
class=
"form-floating"
>
<input
type=
"password"
class=
"form-control"
id=
"floatingPassword"
placeholder=
"Password"
>
<label
for=
"floatingPassword"
>
Password
</label>
</div>
<div
class=
"checkbox mb-3"
>
<label>
<input
type=
"checkbox"
value=
"remember-me"
>
Remember me
</label>
</div>
<button
class=
"w-100 btn btn-lg btn-primary"
type=
"submit"
>
Sign in
</button>
</form>
</main>
<div
th:replace=
"~{fragments/footer :: footer}"
>
©
2022 - 2023
</div>
</div>
<div
th:replace=
"~{fragments/footer :: footer}"
>
©
2022 - 2023
</div>
</div>
</body>
...
...
auth-server-demo/src/main/resources/templates/register.html
浏览文件 @
b9107f54
...
...
@@ -38,11 +38,11 @@
</form> -->
<form
method=
"post"
role=
"form"
th:action=
"@{/register/save}"
th:object=
"${user}"
>
<img
class=
"mb-4"
th:src=
"@{/static/img/logo.svg}"
alt=
""
width=
"72"
height=
"57"
>
<h1
class=
"h3 mb-3 fw-normal"
>
Please register
with following
</h1>
<h1
class=
"h3 mb-3 fw-normal"
>
Please register
</h1>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
First N
ame
</label>
<input
class=
"form-control"
id=
"
firstName"
name=
"firstName"
placeholder=
"Enter first n
ame"
<label
class=
"form-label"
for=
"controlFirstName"
>
First n
ame
</label>
<input
class=
"form-control"
id=
"
controlFirstName"
placeholder=
"First N
ame"
th:field=
"*{firstName}"
type=
"text"
/>
<p
th:errors=
"*{firstName}"
class=
"text-danger"
th:if=
"${#fields.hasErrors('firstName')}"
>
</p>
...
...
@@ -55,6 +55,7 @@
<p
th:errors=
"*{lastName}"
class=
"text-danger"
th:if=
"${#fields.hasErrors('lastName')}"
>
</p>
</div>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
Email
</label>
<input
class=
"form-control"
id=
"email"
name=
"email"
placeholder=
"Enter email address"
...
...
@@ -62,6 +63,7 @@
<p
th:errors=
"*{email}"
class=
"text-danger"
th:if=
"${#fields.hasErrors('email')}"
>
</p>
</div>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
Password
</label>
<input
class=
"form-control"
id=
"password"
name=
"password"
placeholder=
"Enter password"
...
...
@@ -72,16 +74,13 @@
<div
class=
"form-group mb-3"
>
<button
class=
"btn btn-primary"
type=
"submit"
>
Register
</button>
<span>
Already registered?
<a
href=
"/"
th:href=
"@{/login}"
>
Login
here
</a></span>
<span>
Already registered?
<a
href=
"/"
th:href=
"@{/login}"
>
Login here
</a></span>
</div>
</form>
</main>
<div
th:replace=
"~{fragments/footer :: footer}"
>
©
2022 - 2023
</div>
</div>
</body>
</html>
\ No newline at end of file
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录