Skip to content

Commit

Permalink
Merge pull request #15 from vanyouseea/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vanyouseea authored May 26, 2021
2 parents f10e8bc + a52d10d commit 786082d
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>hqr</groupId>
<artifactId>o365</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
<name>o365</name>
<description>Manage office 365</description>
<properties>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/hqr/o365/ctrl/UserTabCtrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> map = cou.createCommonUser(mailNickname, userPrincipalName, displayName, licenses);
HashMap<String, String> map = cou.createCommonUser(mailNickname, userPrincipalName, displayName, licenses, userPwd);

return map.get("message");
}
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/hqr/o365/service/CreateOfficeUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,23 @@ public class CreateOfficeUser {
@Value("${UA}")
private String ua;

public HashMap<String, String> createCommonUser(String mailNickname, String userPrincipalName, String displayName, String licenses){
public HashMap<String, String> createCommonUser(String mailNickname, String userPrincipalName, String displayName, String licenses, String userPwd){
HashMap<String, String> map = new HashMap<String, String>();
String password = "Mjj@1234";
Optional<TaMasterCd> opt = tmr.findById("DEFAULT_PASSWORD");
String forceInd = "Y";
Optional<TaMasterCd> 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
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/ta_master_cd.sql
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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;
58 changes: 51 additions & 7 deletions src/main/resources/templates/tabs/dialogs/createUser.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,32 @@

</head>
<body>
<table style="padding:10px;margin-bottom: 10px">
<table style="padding:10px">
<tr>
<td>名字:</td>
<td colSpan="2"><input id="displayName" class="easyui-validatebox tb" data-options="required:true" style="width: 330px" ></td>
<td colSpan="2"><input id="displayName" class="easyui-textbox" data-options="required:true" style="width: 310px" ></td>
</tr>
<tr>
<td>邮箱:</td>
<td><input id="prefix" class="easyui-validatebox tb" data-options="required:true" style="width: 90px" ></td>
<td><input id="prefix" class="easyui-textbox" data-options="required:true" style="width: 90px" ></td>
<td>
<input id="cc1" name="dept" value="Loading..." style="width: 236px">
<input id="cc1" name="dept" value="Loading..." style="width: 216px">
</td>
</tr>
<tr>
<td>密码:</td>
<td colSpan="2">
<div id="userPwd" name="userPwd"></div>
<!--
<input id="userPwd" name="userPwd" class="easyui-textbox" data-options="required:true,value:'Mjj@1234',iconCls:'icon-reload'" style="width: 310px">
-->
</td>
</tr>
<tr>
<td>订阅:</td>
<td colSpan="2" id="licenseTd">
<div th:each="list : ${session.licenseVo}" style="font-size: 12px">
<input class="easyui-checkbox" name="checkbox1" th:value="${list.skuId}" th:label="${list.skuPartNumber}" labelWidth="310px" ><br>
<input class="easyui-checkbox" name="checkbox1" th:value="${list.skuId}" th:label="${list.skuPartNumber}" labelWidth="290px" ><br>
</div>
</td>
</tr>
Expand All @@ -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:'错误',
Expand Down Expand Up @@ -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:'结果',
Expand All @@ -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);
}
</script>

</body>
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/tabs/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
Expand Down Expand Up @@ -383,7 +383,7 @@
'<b>2.</b>详情可以看到用户的订阅skuid和身份,skuid对应的产品名称可以在<a href=javascript:addPanel("查看许可证")>查看许可证</a>找到<br>' +
'<b>3.</b>启用和禁用用户只会对普通用户有效<br>'+
'<b>4.</b>提权和撤权分别是提升一个用户为全局管理员和撤销一个用户的全局管理员权限<br> '+
'<b>5.</b>默认新用户密码是Mjj@1234,你可以在<a href=javascript:addPanel("系统配置")>系统配置</a>中,通过修改DEFAULT_PASSWORD的值来自定义','');
'<b>5.</b>默认新用户密码是Mjj@1234,你也可以自己定义密码或者生成随机密码,同时在<a href=javascript:addPanel("系统配置")>系统配置</a>中,你可以通过修改FORCE_CHANGE_PASSWORD=N来避免用户登录时修改密码','');
}
}],
columns : [[
Expand Down

0 comments on commit 786082d

Please sign in to comment.