Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
09e653c8
提交
09e653c8
authored
10月 16, 2020
作者:
Whispa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit
上级
bce4bc88
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
67 行增加
和
9 行删除
+67
-9
AuthController.java
...a/com/example/afrishop_v3/controllers/AuthController.java
+34
-2
Controller.java
.../java/com/example/afrishop_v3/controllers/Controller.java
+33
-0
UserController.java
...a/com/example/afrishop_v3/controllers/UserController.java
+0
-7
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/AuthController.java
浏览文件 @
09e653c8
...
...
@@ -115,8 +115,42 @@ public class AuthController extends Controller {
String
email
=
signUpRequest
.
getEmail
();
String
password
=
signUpRequest
.
getPassword
();
email
=
email
==
null
?
""
:
email
.
trim
();
if
(
email
.
isEmpty
()
){
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Email is empty"
);
}
if
(
!
isEmailValid
(
email
)
){
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Invalid email"
);
}
if
(
password
==
null
||
password
.
isEmpty
()
){
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Password is Empty"
);
}
if
(
!
isPasswordValid
(
password
)
){
String
string
=
"Password is not strong"
;
if
(
!
isPasswordValidDigit
(
password
)
){
string
+=
", a digit must occur at least once"
;
}
if
(
!
isPasswordValidUpperCase
(
password
)
){
string
+=
", an upper case letter must occur at least once"
;
}
if
(
!
isPasswordValidLength
(
password
)
){
string
+=
", at least eight characters though"
;
}
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
string
);
}
boolean
byEmail
=
userRepository
.
existsByFirebaseUid
(
email
);
if
(
byEmail
)
{
...
...
@@ -131,8 +165,6 @@ public class AuthController extends Controller {
fillUserNecessayInfo
(
signUpRequest
);
String
password
=
signUpRequest
.
getPassword
();
signUpRequest
.
setPassword
(
encoder
.
encode
(
password
));
signUpRequest
.
setLastLoginTime
(
new
Date
());
...
...
src/main/java/com/example/afrishop_v3/controllers/Controller.java
浏览文件 @
09e653c8
...
...
@@ -26,6 +26,8 @@ import java.io.InputStream;
import
java.text.DecimalFormat
;
import
java.text.NumberFormat
;
import
java.util.HashMap
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
abstract
class
Controller
{
...
...
@@ -34,6 +36,37 @@ abstract class Controller {
}
static
boolean
isEmailValid
(
String
email
)
{
return
validRex
(
email
,
"^[\\w.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$"
);
}
static
boolean
isPasswordVeryStrong
(
String
password
)
{
return
validRex
(
password
,
"^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=])(?=\\S+$).{8,}$"
);
}
static
boolean
isPasswordValid
(
String
password
)
{
return
validRex
(
password
,
"^(?=.*[0-9])(?=.*[A-Z]).{8,}$"
);
}
static
boolean
isPasswordValidDigit
(
String
password
)
{
return
validRex
(
password
,
"^(?=.*[0-9])$"
);
}
static
boolean
isPasswordValidUpperCase
(
String
password
)
{
return
validRex
(
password
,
"^(?=.*[A-Z])$"
);
}
static
boolean
isPasswordValidLength
(
String
password
)
{
return
validRex
(
password
,
"^.{8,}$"
);
}
private
static
boolean
validRex
(
String
text
,
String
expression
){
Pattern
pattern
=
Pattern
.
compile
(
expression
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
matcher
=
pattern
.
matcher
(
text
);
return
matcher
.
matches
();
}
static
int
id
=
0
;
NumberFormat
formatter
=
new
DecimalFormat
(
"#0.00"
);
...
...
src/main/java/com/example/afrishop_v3/controllers/UserController.java
浏览文件 @
09e653c8
...
...
@@ -29,13 +29,6 @@ public class UserController extends Controller {
this
.
user
=
user
;
}
private
static
boolean
isEmailValid
(
String
email
)
{
String
expression
=
"^[\\w.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$"
;
Pattern
pattern
=
Pattern
.
compile
(
expression
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
matcher
=
pattern
.
matcher
(
email
);
return
matcher
.
matches
();
}
@PutMapping
(
"bindPhoneOrEmail"
)
public
Result
bindPhoneOrEmail
(
@RequestParam
(
value
=
"email"
,
required
=
false
)
String
email
,
@RequestParam
(
value
=
"code"
,
required
=
false
)
String
code
,
@RequestParam
(
value
=
"phone"
,
required
=
false
)
String
phone
){
TbCfUserInfo
user
=
this
.
user
.
user
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论