Commit 3df13574f32594ccfa5814a449ff257fcacf9dc9

Authored by 谭毅彬
1 parent c22e97fc

系统认证相关代码提交(3)

Signed-off-by: TanYibin <5491541@qq.com>
ant-design-vue-jeecg/src/api/api.js
... ... @@ -18,6 +18,8 @@ const frozenBatch = (params) =&gt; putAction(&quot;/sys/user/frozenBatch&quot;, params);
18 18 const checkOnlyUser = (params) => getAction("/sys/user/checkOnlyUser", params);
19 19 //改变密码
20 20 const changePassword = (params) => putAction("/sys/user/changePassword", params);
  21 +//激活码校验
  22 +const systemActivation = (params) => postAction("/sys/systemActivation", params);
21 23  
22 24 //权限管理
23 25 const addPermission = (params) => postAction("/sys/permission/add", params);
... ... @@ -229,6 +231,7 @@ export {
229 231 frozenBatch,
230 232 checkOnlyUser,
231 233 changePassword,
  234 + systemActivation,
232 235 getPermissionList,
233 236 addPermission,
234 237 editPermission,
... ... @@ -274,6 +277,3 @@ export {
274 277 getUserNoticeInfo,
275 278 getDictItemsFromCache
276 279 }
277   -
278   -
279   -
... ...
ant-design-vue-jeecg/src/router/index.js
... ... @@ -9,4 +9,11 @@ export default new Router({
9 9 base: process.env.BASE_URL,
10 10 scrollBehavior: () => ({y: 0}),
11 11 routes: constantRouterMap
12   -})
13 12 \ No newline at end of file
  13 +})
  14 +
  15 +const originalPush = Router.prototype.push;
  16 +Router.prototype.push = function push(location, onResolve, onReject) {
  17 + if (onResolve || onReject)
  18 + return originalPush.call(this, location, onResolve, onReject);
  19 + return originalPush.call(this, location).catch((err) => err);
  20 +};
14 21 \ No newline at end of file
... ...
ant-design-vue-jeecg/src/views/user/modules/SystemActivationModal.vue
1 1 <template>
2 2 <div class="main">
3   - <a-form-model class="user-layout-login" @keyup.enter.native="handleSubmit" :rules="validatorRules">
  3 + <a-form-model class="user-layout-login" @keyup.enter.native="handleSubmit" :model="model" :rules="validatorRules">
4 4 <a-tabs :activeKey="customActiveKey" :tabBarStyle="{ textAlign: 'center', borderBottom: 'unset' }" @change="handleTabClick">
5 5 <a-tab-pane key="tab1" tab="激活码授权">
6 6 <!-- <login-account ref="alogin" @validateFail="validateFail" @success="requestSuccess" @fail="requestFailed"></login-account> -->
... ... @@ -30,6 +30,7 @@ import {ACCESS_TOKEN, ENCRYPTED_STRING} from &#39;@/store/mutation-types&#39;
30 30 import TwoStepCaptcha from '@/components/tools/TwoStepCaptcha'
31 31 import {getEncryptedString} from '@/utils/encryption/aesEncrypt'
32 32 import {timeFix} from '@/utils/util'
  33 +import {systemActivation} from '@/api/api'
33 34  
34 35 export default {
35 36 components: {
... ... @@ -50,11 +51,10 @@ export default {
50 51 model: {
51 52 activationCode: ''
52 53 },
53   -
54 54 validatorRules: {
55 55 activationCode: [{
56 56 required: true, message: '请输入激活码', validator: 'click'
57   - }]
  57 + }],
58 58 }
59 59 }
60 60 },
... ... @@ -100,45 +100,12 @@ export default {
100 100 callback(err)
101 101 })
102 102 },
103   - //登录
  103 + //验证激活码
104 104 handleSubmit() {
105 105 this.loginBtn = true;
106 106 console.log('handleSubmit start')
107 107 this.handleSystemActivation(this.rememberMe)
108 108 },
109   - // 校验失败
110   - validateFail() {
111   - this.loginBtn = false;
112   - },
113   - // 登录后台成功
114   - requestSuccess(loginResult) {
115   - this.$refs.loginSelect.show(loginResult)
116   - },
117   - //登录后台失败
118   - requestFailed(err) {
119   - let description = ((err.response || {}).data || {}).message || err.message || "请求出现错误,请稍后再试"
120   - this.$notification['error']({
121   - message: '登录失败',
122   - description: description,
123   - duration: 4,
124   - });
125   - //账户密码登录错误后更新验证码
126   - if (this.customActiveKey === 'tab1' && description.indexOf('密码错误') > 0) {
127   - this.$refs.alogin.handleChangeCheckCode()
128   - }
129   - this.loginBtn = false;
130   - },
131   - loginSelectOk() {
132   - this.loginSuccess()
133   - },
134   - //登录成功
135   - loginSuccess() {
136   - this.$router.push({path: "/dashboard/analysis"});
137   - this.$notification.success({
138   - message: '欢迎',
139   - description: `${timeFix()},欢迎回来`,
140   - });
141   - },
142 109 systemActivationSuccess() {
143 110 this.$router.push({path: "/user/login"});
144 111 this.$notification.success({
... ... @@ -146,22 +113,13 @@ export default {
146 113 // description: `${timeFix()},欢迎回来`,
147 114 });
148 115 },
149   - systemActivationSuccessError() {
  116 + systemActivationSuccessError(message) {
150 117 this.$notification.error({
151   - message: '激活失败,请重新输入',
  118 + message: message,
152 119 // description: `${timeFix()},欢迎回来`,
153 120 });
154 121 this.loginBtn = false;
155 122 },
156   - stepCaptchaSuccess() {
157   - this.loginSuccess()
158   - },
159   - stepCaptchaCancel() {
160   - this.Logout().then(() => {
161   - this.loginBtn = false
162   - this.stepCaptchaVisible = false
163   - })
164   - },
165 123 //获取密码加密规则
166 124 getEncrypte() {
167 125 var encryptedString = Vue.ls.get(ENCRYPTED_STRING);
... ... @@ -174,18 +132,18 @@ export default {
174 132 }
175 133 },
176 134 handleSystemActivation(rememberMe) {
177   - console.log('handleLogin start')
178   - let loginParams = {
  135 + console.log('handleSystemActivation start')
  136 + let systemActivationModelParams = {
179 137 activationCode: this.model.activationCode,
180 138 }
181   - // this.systemActivationSuccess();
182   - this.systemActivationSuccessError();
183   - // this.loginSelectOk();
184   - // this.Login(loginParams).then((res) => {
185   - // this.$emit('success', res.result)
186   - // }).catch((err) => {
187   - // this.$emit('fail', err)
188   - // });
  139 + systemActivation(systemActivationModelParams).then((res) => {
  140 + this.loading = false;
  141 + if (res.success) {
  142 + this.systemActivationSuccess();
  143 + } else {
  144 + this.systemActivationSuccessError(res.message);
  145 + }
  146 + });
189 147 }
190 148 }
191 149 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/LoginController.java
... ... @@ -33,7 +33,7 @@ import org.jeecg.modules.system.entity.SysDepart;
33 33 import org.jeecg.modules.system.entity.SysTenant;
34 34 import org.jeecg.modules.system.entity.SysUser;
35 35 import org.jeecg.modules.system.model.SysLoginModel;
36   -import org.jeecg.modules.system.model.SystemAuthenticationModel;
  36 +import org.jeecg.modules.system.model.SystemActivationModel;
37 37 import org.jeecg.modules.system.service.ISysDepartService;
38 38 import org.jeecg.modules.system.service.ISysDictService;
39 39 import org.jeecg.modules.system.service.ISysLogService;
... ... @@ -162,6 +162,7 @@ public class LoginController {
162 162 result.error500("请选择仓库编码");
163 163 return result;
164 164 }
  165 + // 激活信息认证
165 166 // result = HuahengJwtUtil.checkSystemActivationCode();
166 167 // if (!result.isSuccess()) {
167 168 // return result;
... ... @@ -180,9 +181,9 @@ public class LoginController {
180 181  
181 182 @ApiOperation("系统激活API")
182 183 @RequestMapping(value = "/systemActivation", method = RequestMethod.POST)
183   - public Result<JSONObject> systemAuthentication(@RequestBody SystemAuthenticationModel systemAuthenticationModel) throws IOException {
  184 + public Result<JSONObject> systemAuthentication(@RequestBody SystemActivationModel systemActivationModel) throws IOException {
184 185 Result<JSONObject> result = new Result<JSONObject>();
185   - if (StringUtils.isEmpty(systemAuthenticationModel.getActivationCode())) {
  186 + if (StringUtils.isEmpty(systemActivationModel.getActivationCode())) {
186 187 result.error500("请输入激活码");
187 188 return result;
188 189 }
... ... @@ -191,14 +192,14 @@ public class LoginController {
191 192 Algorithm algorithm = Algorithm.RSA256(new SystemRSA256Key().getPublicKey(), new SystemRSA256Key().getPrivateKey());
192 193 JWTVerifier verifier =
193 194 JWT.require(algorithm).withClaim("operator", HuahengJwtUtil.HUAHENG_SYSTEM_ID).withIssuer(HuahengJwtUtil.HUAHENG_SYSTEM_ID).build();
194   - DecodedJWT jwt = verifier.verify(systemAuthenticationModel.getActivationCode());
  195 + DecodedJWT jwt = verifier.verify(systemActivationModel.getActivationCode());
195 196 new ApiAuthentication.ApiAuthenticationBuild().operator(jwt.getClaim("operator").asString()).audience(jwt.getAudience().get(0)).issuer(jwt.getIssuer())
196 197 .issuedAt(jwt.getIssuedAt()).expireDateTime(jwt.getExpiresAt()).bulid();
197 198  
198 199 // 验证通过写入文件
199 200 File file = new File(System.getProperties().getProperty("user.dir") + File.separatorChar + HuahengJwtUtil.SYSTEM_ACTIVATION_CODE_FILE_NAME);
200 201 outputStream = new FileOutputStream(file, false);
201   - FileCopyUtils.copy(systemAuthenticationModel.getActivationCode().getBytes(), outputStream);
  202 + FileCopyUtils.copy(systemActivationModel.getActivationCode().getBytes(), outputStream);
202 203 } catch (JWTVerificationException e) {
203 204 log.error(e.getMessage());
204 205 result.error500("激活失败");
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/system/model/SystemAuthenticationModel.java renamed to huaheng-wms-core/src/main/java/org/jeecg/modules/system/model/SystemActivationModel.java
... ... @@ -11,7 +11,7 @@ import lombok.Data;
11 11 */
12 12 @Data
13 13 @ApiModel(value = "系统认证对象", description = "系统认证对象")
14   -public class SystemAuthenticationModel {
  14 +public class SystemActivationModel {
15 15  
16 16 @ApiModelProperty(value = "ActivationCode")
17 17 private String activationCode;
... ...
huaheng-wms-core/src/main/resources/application-dev.yml
... ... @@ -138,7 +138,7 @@ spring:
138 138 master:
139 139 url: jdbc:log4jdbc:mysql://localhost:3306/wms4?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
140 140 username: root
141   - password: HHsoft123.
  141 + password: 123456
142 142 driver-class-name: net.sf.log4jdbc.DriverSpy
143 143 # sqlserver 数据源配置
144 144 # url: jdbc:sqlserver://172.16.29.88:1433;DatabaseName=wms4;encrypt=false;SelectMethod=cursor;
... ... @@ -159,9 +159,9 @@ spring:
159 159 #redis 配置
160 160 redis:
161 161 database: 0
162   - host: 172.16.29.77
  162 + host: 127.0.0.1
163 163 port: 6379
164   - password: 123456
  164 + password:
165 165 lettuce:
166 166 pool:
167 167 min-idle: 0 #最小等待连接中的数量,设 0 为没有限制
... ... @@ -208,7 +208,7 @@ jeecg:
208 208 #webapp文件路径
209 209 webapp: ./webapp
210 210 shiro:
211   - excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/api/**,/sys/cas/client/validateLogin,/sys/common/static/**,/sys/systemAuthentication
  211 + excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/api/**,/sys/cas/client/validateLogin,/sys/common/static/**,/sys/systemActivation
212 212 #阿里云oss存储和大鱼短信秘钥配置
213 213 oss:
214 214 accessKey: ??
... ... @@ -281,8 +281,8 @@ jeecg:
281 281 data-type: database
282 282 #分布式锁配置
283 283 redisson:
284   - address: 172.16.29.77:6379
285   - password: 123456
  284 + address: 127.0.0.1:6379
  285 + password:
286 286 type: STANDALONE
287 287 enabled: true
288 288 #cas单点登录
... ...
huaheng-wms-core/src/main/resources/application-prod.yml
... ... @@ -208,7 +208,7 @@ jeecg:
208 208 #webapp文件路径
209 209 webapp: ./webapp
210 210 shiro:
211   - excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/api/**,/sys/cas/client/validateLogin,/sys/common/static/**,/sys/systemAuthentication
  211 + excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/api/**,/sys/cas/client/validateLogin,/sys/common/static/**,/sys/systemActivation
212 212 #阿里云oss存储和大鱼短信秘钥配置
213 213 oss:
214 214 accessKey: ??
... ...
huaheng-wms-core/src/main/resources/application-test.yml
... ... @@ -209,7 +209,7 @@ jeecg:
209 209 #webapp文件路径
210 210 webapp: ./webapp
211 211 shiro:
212   - excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/api/**,/sys/cas/client/validateLogin,/sys/common/static/**,/sys/systemAuthentication
  212 + excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/api/**,/sys/cas/client/validateLogin,/sys/common/static/**,/sys/systemActivation
213 213 #阿里云oss存储和大鱼短信秘钥配置
214 214 oss:
215 215 accessKey: ??
... ...