Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
MaxKey
提交
f34af437
MaxKey
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
MaxKey
大约 1 年 前同步成功
通知
76
Star
3
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f34af437
编写于
10月 26, 2020
作者:
F
fucan1017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
注册功能
上级
72785110
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
215 addition
and
46 deletion
+215
-46
maxkey-core/src/main/java/org/maxkey/util/StringUtils.java
maxkey-core/src/main/java/org/maxkey/util/StringUtils.java
+39
-0
maxkey-persistence/src/main/java/org/maxkey/persistence/mapper/UserInfoMapper.java
...in/java/org/maxkey/persistence/mapper/UserInfoMapper.java
+1
-1
maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java
.../src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java
+50
-0
maxkey-web-maxkey/src/main/resources/messages/message.properties
...web-maxkey/src/main/resources/messages/message.properties
+5
-0
maxkey-web-maxkey/src/main/resources/messages/message_en.properties
...-maxkey/src/main/resources/messages/message_en.properties
+5
-0
maxkey-web-maxkey/src/main/resources/messages/message_zh_CN.properties
...xkey/src/main/resources/messages/message_zh_CN.properties
+5
-0
maxkey-web-maxkey/src/main/resources/templates/views/login.ftl
...y-web-maxkey/src/main/resources/templates/views/login.ftl
+3
-0
maxkey-web-maxkey/src/main/resources/templates/views/registration/register.ftl
.../main/resources/templates/views/registration/register.ftl
+107
-45
未找到文件。
maxkey-core/src/main/java/org/maxkey/util/StringUtils.java
浏览文件 @
f34af437
...
...
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
final
class
StringUtils
{
...
...
@@ -479,4 +480,42 @@ public final class StringUtils {
}
return
null
;
}
/**
* 验证是否为正确的邮箱号
*
* @param email
* @return
*/
public
static
boolean
isValidEmail
(
String
email
)
{
// 1、\\w+表示@之前至少要输入一个匹配字母或数字或下划线 \\w 单词字符:[a-zA-Z_0-9]
// 2、(\\w+\\.)表示域名. 如新浪邮箱域名是sina.com.cn
// {1,3}表示可以出现一次或两次或者三次.
String
reg
=
"\\w+@(\\w+\\.){1,3}\\w+"
;
Pattern
pattern
=
Pattern
.
compile
(
reg
);
boolean
flag
=
false
;
if
(
email
!=
null
)
{
Matcher
matcher
=
pattern
.
matcher
(
email
);
flag
=
matcher
.
matches
();
}
return
flag
;
}
/**
* 验证是否为手机号
*
* @param mobileNo
* @return
*/
public
static
boolean
isValidMobileNo
(
String
mobileNo
)
{
// 1、(13[0-9])|(15[02789])|(18[679])|(17[0-9]) 13段 或者15段 18段17段的匹配
// 2、\\d{8} 整数出现8次
boolean
flag
=
false
;
Pattern
p
=
Pattern
.
compile
(
"^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\\d{8}$"
);
Matcher
match
=
p
.
matcher
(
mobileNo
);
if
(
mobileNo
!=
null
)
{
flag
=
match
.
matches
();
}
return
flag
;
}
}
maxkey-persistence/src/main/java/org/maxkey/persistence/mapper/UserInfoMapper.java
浏览文件 @
f34af437
...
...
@@ -60,7 +60,7 @@ public interface UserInfoMapper extends IJpaBaseMapper<UserInfo>{
public
int
updateProfile
(
UserInfo
userInfo
);
@Select
(
"SELECT * FROM USERINFO WHERE EMAIL = #{value} OR MOBILE= #{value}"
)
@Select
(
"SELECT * FROM
MXK_
USERINFO WHERE EMAIL = #{value} OR MOBILE= #{value}"
)
public
UserInfo
queryUserInfoByEmailMobile
(
String
emailMobile
);
}
maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java
浏览文件 @
f34af437
...
...
@@ -31,12 +31,15 @@ import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
import
org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService
;
import
org.maxkey.authn.support.wsfederation.WsFederationConstants
;
import
org.maxkey.configuration.ApplicationConfig
;
import
org.maxkey.constants.ConstantsOperateMessage
;
import
org.maxkey.constants.ConstantsStatus
;
import
org.maxkey.crypto.password.opt.AbstractOptAuthn
;
import
org.maxkey.domain.UserInfo
;
import
org.maxkey.persistence.service.UserInfoService
;
import
org.maxkey.util.StringUtils
;
import
org.maxkey.web.WebConstants
;
import
org.maxkey.web.WebContext
;
import
org.maxkey.web.message.Message
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -222,4 +225,51 @@ public class LoginEndpoint {
return
"fail"
;
}
/**
* view register
* @return
*/
@RequestMapping
(
value
={
"/register"
})
public
ModelAndView
register
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
_logger
.
debug
(
"LoginController /register."
);
ModelAndView
modelAndView
=
new
ModelAndView
(
"registration/register"
);
Object
loginErrorMessage
=
WebContext
.
getAttribute
(
WebConstants
.
LOGIN_ERROR_SESSION_MESSAGE
);
modelAndView
.
addObject
(
"loginErrorMessage"
,
loginErrorMessage
==
null
?
""
:
loginErrorMessage
);
WebContext
.
removeAttribute
(
WebConstants
.
LOGIN_ERROR_SESSION_MESSAGE
);
return
modelAndView
;
}
@RequestMapping
(
value
={
"/registeron"
})
@ResponseBody
public
Message
registeron
(
UserInfo
userInfo
,
@RequestParam
String
emailMobile
)
throws
ServletException
,
IOException
{
if
(
StringUtils
.
isNullOrBlank
(
emailMobile
))
{
return
new
Message
(
WebContext
.
getI18nValue
(
"register.emailMobile.error"
),
"1"
);
}
if
(
StringUtils
.
isValidEmail
(
emailMobile
))
{
userInfo
.
setEmail
(
emailMobile
);
}
if
(
StringUtils
.
isValidMobileNo
(
emailMobile
))
{
userInfo
.
setMobile
(
emailMobile
);
}
if
(!(
StringUtils
.
isValidEmail
(
emailMobile
)||
StringUtils
.
isValidMobileNo
(
emailMobile
)))
{
return
new
Message
(
WebContext
.
getI18nValue
(
"register.emailMobile.error"
),
"1"
);
}
UserInfo
temp
=
userInfoService
.
queryUserInfoByEmailMobile
(
emailMobile
);
if
(
temp
!=
null
)
{
return
new
Message
(
WebContext
.
getI18nValue
(
"register.emailMobile.exist"
),
"1"
);
}
temp
=
userInfoService
.
loadByUsername
(
userInfo
.
getUsername
());
if
(
temp
!=
null
)
{
return
new
Message
(
WebContext
.
getI18nValue
(
"register.user.error"
),
"1"
);
}
userInfo
.
setStatus
(
ConstantsStatus
.
ACTIVE
);
if
(
userInfoService
.
insert
(
userInfo
))
{
return
new
Message
(
WebContext
.
getI18nValue
(
"login.text.register.success"
),
"0"
);
}
return
new
Message
(
WebContext
.
getI18nValue
(
"login.text.register.error"
),
"1"
);
}
}
maxkey-web-maxkey/src/main/resources/messages/message.properties
浏览文件 @
f34af437
...
...
@@ -53,6 +53,11 @@ login.button.login=\u767b\u5f55
login.text.currenttime
=
\u
65f6
\u
95f4
login.text.otherlogins
=
\u5176\u
4ed6
\u
767b
\u
5f55
\u
65b9
\u
5f0f
login.text.register
=
\u7528\u6237\u
6ce8
\u
518c
login.text.register.success
=
\u
6ce8
\u
518c
\u6210\u
529f
login.text.register.error
=
\u
6ce8
\u
518c
\u5931\u
8d25
\u
000d
\u
000a
register.user.error
=
\u
767B
\u9646\u
8D26
\u
53F7
\u
5DF2
\u
5B58
\u5728
register.emailMobile.error
=
\u
90AE
\u
7BB1
\u6216\u
624B
\u
673A
\u
683C
\u
5F0F
\u9519\u
8BEF
register.emailMobile.exist
=
\u
90AE
\u
7BB1
\u6216\u
624B
\u
673A
\u
5DF2
\u
5B58
\u5728
login.password.expired
=
\u
5bc6
\u7801\u
8fc7
\u
671f
login.password.expired.tip
=
\u
5bc6
\u7801\u
8fc7
\u
671f
\u
ff0c
\u
8bf7
\u
4fee
\u6539\u
5bc6
\u7801
...
...
maxkey-web-maxkey/src/main/resources/messages/message_en.properties
浏览文件 @
f34af437
...
...
@@ -53,6 +53,11 @@ login.button.login=Login
login.text.currenttime
=
CurrentTime
login.text.otherlogins
=
OtherLogins
login.text.register
=
Register
login.text.register.success
=
Register successful
login.text.register.error
=
Register error
register.user.error
=
username exist
register.emailMobile.error
=
email or mobile error
register.emailMobile.exist
=
email or mobile exist
login.password.expired
=
Password Expired
login.password.expired.tip
=
Password expired, please change password
...
...
maxkey-web-maxkey/src/main/resources/messages/message_zh_CN.properties
浏览文件 @
f34af437
...
...
@@ -53,6 +53,11 @@ login.button.login=\u767b\u5f55
login.text.currenttime
=
\u
65f6
\u
95f4
login.text.otherlogins
=
\u5176\u
4ed6
\u
767b
\u
5f55
\u
65b9
\u
5f0f
login.text.register
=
\u7528\u6237\u
6ce8
\u
518c
login.text.register.success
=
\u
6ce8
\u
518c
\u6210\u
529f
login.text.register.error
=
\u
6ce8
\u
518c
\u5931\u
8d25
\u
000d
\u
000a
register.user.error
=
\u
767B
\u9646\u
8D26
\u
53F7
\u
5DF2
\u
5B58
\u5728
register.emailMobile.error
=
\u
90AE
\u
7BB1
\u6216\u
624B
\u
673A
\u
683C
\u
5F0F
\u9519\u
8BEF
register.emailMobile.exist
=
\u
90AE
\u
7BB1
\u6216\u
624B
\u
673A
\u
5DF2
\u
5B58
\u5728
login.password.expired
=
\u
5bc6
\u7801\u
8fc7
\u
671f
login.password.expired.tip
=
\u
5bc6
\u7801\u
8fc7
\u
671f
\u
ff0c
\u
8bf7
\u
4fee
\u6539\u
5bc6
\u7801
...
...
maxkey-web-maxkey/src/main/resources/templates/views/login.ftl
浏览文件 @
f34af437
...
...
@@ -168,6 +168,9 @@ $(function(){
<
#
--
todo
:
send
captcha
-->
captchaCountTimer
=
setInterval
(
"
getCaptchaCount()
"
,
1000
);
});
$
(
'
#register
'
).
on
(
'
click
'
,
function
(){
window
.
location
.
href
=
"
<@base />/register
"
;
});
});
</script>
...
...
maxkey-web-maxkey/src/main/resources/templates/views/registration/register.ftl
浏览文件 @
f34af437
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base
href=
"<@base/>"
>
<title>
My JSP 'register.jsp' starting page
</title>
<meta
http-equiv=
"pragma"
content=
"no-cache"
>
<meta
http-equiv=
"cache-control"
content=
"no-cache"
>
<meta
http-equiv=
"expires"
content=
"0"
>
<meta
http-equiv=
"keywords"
content=
"keyword1,keyword2,keyword3"
>
<meta
http-equiv=
"description"
content=
"This is my page"
>
<!DOCTYPE HTML>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<
#include
"../
layout
/
header.ftl
"
>
<
#include
"../
layout
/
common.cssjs.ftl
"
>
<script
type=
"text/javascript"
>
$
(
function
(){
</head>
<body>
$
(
'
#j_captchaimg
'
).
click
(
function
()
{
//
$
(
this
).
attr
(
"
src
"
,
"
<@base />/captcha
"
);
});
$
(
'
#btn_save
'
).
on
(
'
click
'
,
function
(){
if
(
$
(
'
#emailMobile
'
).
val
()
==
''
){
alert
(
'
<@locale code="forgotpassword.emailmobile"/>
'
+
'
: empty
'
);
return
false
;
}
if
(
$
(
'
#username
'
).
val
()
==
''
){
alert
(
'
<@locale code="userinfo.username"/>
'
+
'
: empty
'
);
return
false
;
}
if
(
$
(
'
#displayName
'
).
val
()
==
''
){
alert
(
'
<@locale code="userinfo.displayName"/>
'
+
'
: empty
'
);
return
false
;
}
if
(
$
(
'
#password
'
).
val
()
==
''
){
alert
(
'
<@locale code="login.text.password"/>
'
+
'
: empty
'
);
return
false
;
}
if
(
$
(
'
#confirmpassword
'
).
val
()
==
''
){
alert
(
'
<@locale code="login.password.confirmPassword"/>
'
+
'
: empty
'
);
return
false
;
}
if
(
$
(
'
#password
'
).
val
()
!=
$
(
'
#confirmpassword
'
).
val
()){
alert
(
'
<@locale code="login.password.confirmPassword"/>
'
+
'
、
'
+
'
<@locale code="login.text.password"/>
'
+
'
: error
'
);
return
false
;
}
formSubmit
();
})
function
formSubmit
(){
var
uname
=
$
(
'
#username
'
).
val
();
var
pwd
=
$
(
'
#password
'
).
val
();
var
eMobile
=
$
(
'
#emailMobile
'
).
val
();
var
dName
=
$
(
'
#displayName
'
).
val
();
$
.
ajax
({
type
:
"
POST
"
,
url
:
"
<@base/>/registeron
"
,
data
:{
username
:
uname
,
password
:
pwd
,
emailMobile
:
eMobile
,
displayName
:
dName
},
success
:
function
(
data
){
if
(
data
.
code
==
'
0
'
){
alert
(
data
.
message
);
window
.
location
.
href
=
"
<@base/>/login
"
;
}
else
{
alert
(
data
.
message
);
}
},
error
:
function
(
jqXHR
){
alert
(
"
error:
"
+
jqXHR
.
status
);
}
});
}
});
</script>
</head>
<body
>
<div
id=
"top"
>
<
#include
"../
layout
/
nologintop.ftl
"
>
</div>
<div
class=
"container"
>
<table
border=
"0"
style=
"width:100%;"
>
<tr>
<td
width=
"630px"
>
</td>
<td>
<form
action=
"<@base />/registration/register"
method=
"post"
>
<table
class=
"datatable"
>
<div
class=
"row"
>
<div
class=
"col-md-2"
></div>
<div
class=
"col-md-8"
>
<form
action=
"<@base/>/register.do"
method=
"post"
class=
"needs-validation"
novalidate
>
<table
class=
"table table-bordered"
>
<tr>
<td><
@
locale
code=
"
register.lastnam
e"
/></td>
<td><input
type=
'text'
id=
"lastName"
name=
"lastName"
value=
""
/></td>
<td><
@
locale
code=
"
forgotpassword.emailmobil
e"
/></td>
<td><input
required=
""
type=
"text"
id=
"emailMobile"
name=
"emailMobile"
class=
"form-control"
title=
""
value=
""
/></td>
</tr>
<tr>
<td><
@
locale
code=
"register.firstname"
/></td>
<td><input
type=
'text'
id=
"firstName"
name=
"firstName"
value=
""
/></td>
<td><
@
locale
code=
"login.text.captcha"
/>
:
</td>
<td><input
required=
""
class=
"form-control"
type=
'text'
id=
"j_captcha"
name=
"captcha"
tabindex=
"3"
value=
""
style=
"float: left;"
/><img
id=
"j_captchaimg"
src=
"<@base/>/captcha"
/></td>
</tr>
<tr>
<td><
@
locale
code=
"register.workemail"
/>
</td>
<td><input
type=
'text'
id=
"workEmail"
name=
"workEmail"
value=
""
/></td>
<td><
@
locale
code=
"userinfo.displayName"
/>
:
</td>
<td><input
required=
""
class=
"form-control"
type=
'text'
id=
'displayName'
name=
'displayName'
tabindex=
"1"
/></td>
</tr>
<tr>
<td><
@
locale
code=
"register.company"
/>
</td>
<td><input
type=
'text'
id=
"company"
name=
"company"
value=
""
/></td>
<td><
@
locale
code=
"userinfo.username"
/>
:
</td>
<td><input
required=
""
class=
"form-control"
type=
'text'
id=
'username'
name=
'username'
tabindex=
"1"
/></td>
</tr>
<tr>
<td><
@
locale
code=
"register.workphone"
/></td>
<td><input
type=
'text'
id=
"workPhone"
name=
"workPhone"
value=
""
/></td>
</tr>
<tr
style=
"display:none"
>
<td><
@
locale
code=
"register.users"
/></td>
<td><input
type=
'text'
id=
"users"
name=
"users"
value=
"0"
/></td>
<td><
@
locale
code=
"login.text.password"
/></td>
<td><input
required=
""
class=
"form-control"
type=
'password'
id=
"password"
name=
"password"
tabindex=
"1"
value=
""
/></td>
</tr>
<tr>
<td
colspan=
"2"
><input
id=
"registerBtn"
class=
"button"
type=
"submit"
value=
"<@locale code="
register.button.register
"
/>
"/>
</td>
<td><
@
locale
code=
"login.password.confirmPassword"
/></td>
<td><input
required=
""
class=
"form-control"
type=
'password'
id=
"confirmpassword"
name=
"confirmpassword"
tabindex=
"2"
value=
""
/></td>
</tr>
<tr>
<td
colspan=
"2"
><input
id=
"btn_save"
class=
"button btn btn-lg btn-primary btn-block"
type=
"button"
value=
"<@locale code="
login.text.register
"
/>
"/>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
</body>
</html>
<div
class=
"col-md-2"
></div>
</div
>
</div>
<div
id=
"footer"
>
<
#include
"../
layout
/
footer.ftl
"
>
</div>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录