Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
7c148cc7
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7c148cc7
编写于
9月 08, 2017
作者:
L
lepdou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support user email field
上级
1e165540
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
29 addition
and
5 deletion
+29
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java
...ramework/apollo/portal/controller/UserInfoController.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/UserInfo.java
...com/ctrip/framework/apollo/portal/entity/bo/UserInfo.java
+0
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserPO.java
...a/com/ctrip/framework/apollo/portal/entity/po/UserPO.java
+11
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserService.java
.../portal/spi/springsecurity/SpringSecurityUserService.java
+7
-1
apollo-portal/src/main/resources/static/user-manage.html
apollo-portal/src/main/resources/static/user-manage.html
+8
-0
scripts/sql/apolloportaldb.sql
scripts/sql/apolloportaldb.sql
+1
-0
未找到文件。
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java
浏览文件 @
7c148cc7
...
...
@@ -3,6 +3,7 @@ package com.ctrip.framework.apollo.portal.controller;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.entity.bo.UserInfo
;
import
com.ctrip.framework.apollo.portal.entity.po.UserPO
;
import
com.ctrip.framework.apollo.portal.spi.LogoutHandler
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
...
...
@@ -10,7 +11,6 @@ import com.ctrip.framework.apollo.portal.spi.springsecurity.SpringSecurityUserSe
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.core.userdetails.User
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -38,7 +38,7 @@ public class UserInfoController {
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@RequestMapping
(
value
=
"/users"
,
method
=
RequestMethod
.
POST
)
public
void
createOrUpdateUser
(
@RequestBody
User
user
)
{
public
void
createOrUpdateUser
(
@RequestBody
User
PO
user
)
{
if
(
StringUtils
.
isContainEmpty
(
user
.
getUsername
(),
user
.
getPassword
()))
{
throw
new
BadRequestException
(
"Username and password can not be empty."
);
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/UserInfo.java
浏览文件 @
7c148cc7
package
com.ctrip.framework.apollo.portal.entity.bo
;
public
class
UserInfo
{
public
static
final
UserInfo
DEFAULT_USER
=
new
UserInfo
(
"apollo"
);
private
String
userId
;
private
String
name
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserPO.java
浏览文件 @
7c148cc7
...
...
@@ -23,6 +23,8 @@ public class UserPO {
private
String
username
;
@Column
(
name
=
"Password"
,
nullable
=
false
)
private
String
password
;
@Column
(
name
=
"Email"
,
nullable
=
false
)
private
String
email
;
@Column
(
name
=
"Enabled"
,
nullable
=
false
)
private
int
enabled
;
...
...
@@ -42,6 +44,14 @@ public class UserPO {
this
.
username
=
username
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getPassword
()
{
return
password
;
}
...
...
@@ -62,7 +72,7 @@ public class UserPO {
UserInfo
userInfo
=
new
UserInfo
();
userInfo
.
setName
(
this
.
getUsername
());
userInfo
.
setUserId
(
this
.
getUsername
());
userInfo
.
setEmail
(
this
.
get
Username
()
+
"@acme.com"
);
userInfo
.
setEmail
(
this
.
get
Email
()
);
return
userInfo
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/springsecurity/SpringSecurityUserService.java
浏览文件 @
7c148cc7
...
...
@@ -15,6 +15,7 @@ import org.springframework.security.core.userdetails.User;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.provisioning.JdbcUserDetailsManager
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
...
...
@@ -42,7 +43,8 @@ public class SpringSecurityUserService implements UserService {
authorities
.
add
(
new
SimpleGrantedAuthority
(
"ROLE_user"
));
}
public
void
createOrUpdate
(
User
user
)
{
@Transactional
public
void
createOrUpdate
(
UserPO
user
)
{
String
username
=
user
.
getUsername
();
User
userDetails
=
new
User
(
username
,
encoder
.
encode
(
user
.
getPassword
()),
authorities
);
...
...
@@ -53,6 +55,10 @@ public class SpringSecurityUserService implements UserService {
userDetailsManager
.
createUser
(
userDetails
);
}
UserPO
managedUser
=
userRepository
.
findByUsername
(
username
);
managedUser
.
setEmail
(
user
.
getEmail
());
userRepository
.
save
(
managedUser
);
}
@Override
...
...
apollo-portal/src/main/resources/static/user-manage.html
浏览文件 @
7c148cc7
...
...
@@ -44,6 +44,14 @@
<input
type=
"text"
class=
"form-control"
name=
"password"
ng-model=
"user.password"
>
</div>
</div>
<div
class=
"form-group"
valdr-form-group
>
<label
class=
"col-sm-2 control-label"
>
<apollorequiredfield></apollorequiredfield>
邮箱
</label>
<div
class=
"col-sm-4"
>
<input
type=
"text"
class=
"form-control"
name=
"password"
ng-model=
"user.email"
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-sm-offset-2 col-sm-9"
>
...
...
scripts/sql/apolloportaldb.sql
浏览文件 @
7c148cc7
...
...
@@ -284,6 +284,7 @@ CREATE TABLE `Users` (
`Id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'自增Id'
,
`Username`
varchar
(
64
)
NOT
NULL
DEFAULT
'default'
COMMENT
'用户名'
,
`Password`
varchar
(
64
)
NOT
NULL
DEFAULT
'default'
COMMENT
'密码'
,
`Email`
varchar
(
64
)
NOT
NULL
DEFAULT
'default'
COMMENT
'邮箱地址'
,
`Enabled`
tinyint
(
4
)
DEFAULT
NULL
COMMENT
'是否有效'
,
PRIMARY
KEY
(
`Id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COMMENT
=
'用户表'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录