diff --git a/pom.xml b/pom.xml
index de63f2e..084c16e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
hqr
o365
- 1.1.0
+ 1.1.1
o365
Manage office 365
diff --git a/src/main/java/hqr/o365/ctrl/UserTabCtrl.java b/src/main/java/hqr/o365/ctrl/UserTabCtrl.java
index a1d1eeb..ff95b6f 100644
--- a/src/main/java/hqr/o365/ctrl/UserTabCtrl.java
+++ b/src/main/java/hqr/o365/ctrl/UserTabCtrl.java
@@ -135,9 +135,10 @@ public String getOfficeUser(String page, String rows, HttpServletRequest req) {
public String createUser(@RequestParam(name="mailNickname") String mailNickname,
@RequestParam(name="userPrincipalName") String userPrincipalName,
@RequestParam(name="displayName") String displayName,
- @RequestParam(name="licenses") String licenses) {
+ @RequestParam(name="licenses") String licenses,
+ @RequestParam(name="userPwd") String userPwd) {
- HashMap map = cou.createCommonUser(mailNickname, userPrincipalName, displayName, licenses);
+ HashMap map = cou.createCommonUser(mailNickname, userPrincipalName, displayName, licenses, userPwd);
return map.get("message");
}
diff --git a/src/main/java/hqr/o365/service/CreateOfficeUser.java b/src/main/java/hqr/o365/service/CreateOfficeUser.java
index 2cd0f06..5c8d05d 100644
--- a/src/main/java/hqr/o365/service/CreateOfficeUser.java
+++ b/src/main/java/hqr/o365/service/CreateOfficeUser.java
@@ -51,21 +51,23 @@ public class CreateOfficeUser {
@Value("${UA}")
private String ua;
- public HashMap createCommonUser(String mailNickname, String userPrincipalName, String displayName, String licenses){
+ public HashMap createCommonUser(String mailNickname, String userPrincipalName, String displayName, String licenses, String userPwd){
HashMap map = new HashMap();
- String password = "Mjj@1234";
- Optional opt = tmr.findById("DEFAULT_PASSWORD");
+ String forceInd = "Y";
+ Optional opt = tmr.findById("FORCE_CHANGE_PASSWORD");
if(opt.isPresent()) {
TaMasterCd cd = opt.get();
- password = cd.getCd();
+ forceInd = cd.getCd();
}
OfficeUser ou = new OfficeUser();
ou.setMailNickname(mailNickname);
ou.setUserPrincipalName(userPrincipalName);
ou.setDisplayName(displayName);
- ou.getPasswordProfile().setPassword(password);
-
+ ou.getPasswordProfile().setPassword(userPwd);
+ if(!"Y".equals(forceInd)) {
+ ou.getPasswordProfile().setForceChangePasswordNextSignIn(false);
+ }
String message = "";
//get info
diff --git a/src/main/resources/ta_master_cd.sql b/src/main/resources/ta_master_cd.sql
index b3c9d0b..806999b 100644
--- a/src/main/resources/ta_master_cd.sql
+++ b/src/main/resources/ta_master_cd.sql
@@ -1,6 +1,5 @@
--sys use prop
insert into ta_master_cd(key_ty,cd,decode,start_dt,end_dt,create_dt,last_update_id,last_update_dt) values ('GLOBAL_REG','Y','Y to turn on the function to register the admin user',sysdate,null,sysdate,'o365',sysdate);
-insert into ta_master_cd(key_ty,cd,decode,start_dt,end_dt,create_dt,last_update_id,last_update_dt) values ('DEFAULT_PASSWORD','Mjj@1234','the default password for the new created office user',sysdate,null,sysdate,'o365',sysdate);
insert into ta_master_cd(key_ty,cd,decode,start_dt,end_dt,create_dt,last_update_id,last_update_dt) values ('DEFAULT_ADMIN_ROLE_ID','62e90394-69f5-4237-9190-012177145e10','the default admin role to grant or revoke',sysdate,null,sysdate,'o365',sysdate);
insert into ta_master_cd(key_ty,cd,decode,start_dt,end_dt,create_dt,last_update_id,last_update_dt) values ('SEARCH_ROLE_1','62e90394-69f5-4237-9190-012177145e10','Global Administrator',sysdate,null,sysdate,'o365',sysdate);
@@ -14,4 +13,7 @@ insert into ta_master_cd(key_ty,cd,decode,start_dt,end_dt,create_dt,last_update_
insert into ta_master_cd(key_ty,cd,decode,start_dt,end_dt,create_dt,last_update_id,last_update_dt) values ('GEN_APP_RPT','N','Y to turn on the app overall report everyday',sysdate,null,sysdate,'o365',sysdate);
insert into ta_master_cd(key_ty,cd,decode,start_dt,end_dt,create_dt,last_update_id,last_update_dt) values ('GEN_APP_RPT_RANDOM_SEED','1000','the report default start date is 00:00 + (0~1000)mins everyday',sysdate,null,sysdate,'o365',sysdate);
+insert into ta_master_cd(key_ty,cd,decode,start_dt,end_dt,create_dt,last_update_id,last_update_dt) values ('FORCE_CHANGE_PASSWORD','Y','Y to force user change the password when they login',sysdate,null,sysdate,'o365',sysdate);
+
+
commit;
diff --git a/src/main/resources/templates/tabs/dialogs/createUser.html b/src/main/resources/templates/tabs/dialogs/createUser.html
index 9f88198..fcc9d5a 100644
--- a/src/main/resources/templates/tabs/dialogs/createUser.html
+++ b/src/main/resources/templates/tabs/dialogs/createUser.html
@@ -6,23 +6,32 @@
-
+
名字: |
- |
+ |
邮箱: |
- |
+ |
-
+
+ |
+
+
+ 密码: |
+
+
+
|
订阅: |
-
+
|
@@ -40,11 +49,23 @@
textField:'text'
});
+ $('#userPwd').textbox({
+ required: true,
+ width: 310,
+ value:'Mjj@1234',
+ icons:[{
+ iconCls:'icon-reload',
+ handler: function(e){
+ passwordGen();
+ }
+ }]
+ });
+
function submitForm(){
var mailNickname = $('#prefix').val();
var userPrincipalName = $('#prefix').val() + $('#cc1').combobox('getText');
var displayName = $('#displayName').val();
-
+ var userPwd = $('#userPwd').textbox('getText');
if(mailNickname==''||displayName==''){
$.messager.show({
title:'错误',
@@ -74,7 +95,7 @@
$.ajax({
type : "POST",
url : "/createOfficeUser",
- data : { "mailNickname": mailNickname, "userPrincipalName":userPrincipalName , "displayName": displayName, "licenses": licenses },
+ data : { "mailNickname": mailNickname, "userPrincipalName":userPrincipalName , "displayName": displayName, "licenses": licenses, 'userPwd': userPwd },
success : function(result) {
$.messager.show({
title:'结果',
@@ -99,6 +120,29 @@
function clearForm(){
$('#dlg3').dialog('close');
}
+
+ function passwordGen() {
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+ var string_length = 8;
+ var randomstring = '';
+ var charCount = 0;
+ var numCount = 0;
+
+ for (var i = 0; i < string_length; i++) {
+ // If random bit is 0, there are less than 3 digits already saved, and there are not already 5 characters saved, generate a numeric value.
+ if ((Math.floor(Math.random() * 2) == 0) && numCount < 3 || charCount >= 5) {
+ var rnum = Math.floor(Math.random() * 10);
+ randomstring += rnum;
+ numCount += 1;
+ } else {
+ // If any of the above criteria fail, go ahead and generate an alpha character from the chars string
+ var rnum = Math.floor(Math.random() * chars.length);
+ randomstring += chars.substring(rnum, rnum + 1);
+ charCount += 1;
+ }
+ }
+ $('#userPwd').textbox('setText', randomstring);
+ }
diff --git a/src/main/resources/templates/tabs/user.html b/src/main/resources/templates/tabs/user.html
index ea764aa..4166968 100644
--- a/src/main/resources/templates/tabs/user.html
+++ b/src/main/resources/templates/tabs/user.html
@@ -17,8 +17,8 @@
iconCls: 'icon-add',
modal : true,
closed : true,
- width: 440,
- height: 250,
+ width: 420,
+ height: 290,
cache: false,
href: 'tabs/dialogs/createUser.html'
});
@@ -383,7 +383,7 @@
'2.详情可以看到用户的订阅skuid和身份,skuid对应的产品名称可以在查看许可证找到
' +
'3.启用和禁用用户只会对普通用户有效
'+
'4.提权和撤权分别是提升一个用户为全局管理员和撤销一个用户的全局管理员权限
'+
- '5.默认新用户密码是Mjj@1234,你可以在系统配置中,通过修改DEFAULT_PASSWORD的值来自定义','');
+ '5.默认新用户密码是Mjj@1234,你也可以自己定义密码或者生成随机密码,同时在系统配置中,你可以通过修改FORCE_CHANGE_PASSWORD=N来避免用户登录时修改密码','');
}
}],
columns : [[