Skip to content

Commit bcc4b22

Browse files
committed
usrinfo
1 parent 87af35d commit bcc4b22

File tree

6 files changed

+145
-34
lines changed

6 files changed

+145
-34
lines changed

src/components/Login.vue

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<template>
22
<div>
3-
<el-row>
4-
<el-col :span="8" :offset="8">
3+
<el-row align="center">
4+
<el-col :span="10" :offset="7">
55
<el-tabs type="border-card">
66
<el-tab-pane label="登录">
77
<el-form :model="lgForm">
88
<el-input type="text" v-model="lgForm.username">
9-
<template #prepend>用户名</template>
9+
<template #prepend > <span> 用户名 </span></template>
1010
</el-input>
1111

1212
<el-input type="password" v-model="lgForm.password">
13-
<template #prepend>密码</template>
13+
<template #prepend> <span > 密码 </span> </template>
1414
</el-input>
1515

1616
<el-form-item>
@@ -21,15 +21,15 @@
2121
<el-tab-pane label="注册">
2222
<el-form :model="regForm">
2323
<el-input type="text" v-model="regForm.username">
24-
<template #prepend>用户名</template>
24+
<template #prepend> <span> 用户名 </span> </template>
2525
</el-input>
2626

2727
<el-input type="password" v-model="regForm.password">
28-
<template #prepend>密码</template>
28+
<template #prepend> <span> 密码 </span></template>
2929
</el-input>
3030

3131
<el-input type="password" v-model="regForm.confirm">
32-
<template #prepend>重复密码</template>
32+
<template #prepend> <span> 重复密码 </span></template>
3333
</el-input>
3434
<el-form-item>
3535
<el-button type="info" @click="register"> 注册 </el-button>
@@ -58,6 +58,10 @@ import { ElMessageBox } from "element-plus";
5858
axios.defaults.withCredentials = true;
5959
const aes_key = aes.init_key();
6060
const aes_iv = aes.init_iv();
61+
62+
console.log(aes.b64stringify(aes_key));
63+
console.log(aes.b64stringify(aes_iv));
64+
console.log(aes.encrypt(aes_key, aes_iv, "test"));
6165
export default {
6266
name: "Login",
6367
setup() {
@@ -134,7 +138,7 @@ export default {
134138
this.msFail("请完整填写表单");
135139
return;
136140
}
137-
if (this.regForm.username !== this.regForm.confirm) {
141+
if (this.regForm.password !== this.regForm.confirm) {
138142
this.msFail("密码重复错误");
139143
return;
140144
}
@@ -162,3 +166,10 @@ export default {
162166
};
163167
</script>
164168

169+
<style scoped>
170+
span {
171+
172+
float:left;
173+
width: 50px;
174+
}
175+
</style>

src/components/info.vue

+11-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
:column="1"
1818
v-show="show"
1919
>
20-
<el-descriptions-item label="证书公钥">{{cert.pub_key}}</el-descriptions-item>
20+
<el-descriptions-item label="证书公钥"><pre>{{cert.pub_key}}</pre></el-descriptions-item>
2121
<el-descriptions-item label="证书序列号">{{cert.serial}}</el-descriptions-item>
2222
<el-descriptions-item label="国家" > {{cert.subjectName.C}}</el-descriptions-item>
2323
<el-descriptions-item label="省份"> {{cert.subjectName.ST}} </el-descriptions-item>
@@ -59,12 +59,17 @@ export default {
5959
},
6060
withCredentials: true
6161
}).then((response) => {
62-
if (response.data.error == 1) {
63-
msg.msFail("failed");
64-
} else {
62+
const error_code = response.data.error;
63+
if (error_code == 1) {
64+
msg.msFail("没有与输入序列号所对应的证书");
65+
66+
}
67+
else if (error_code == 2)
68+
{
69+
msg.msFail("用户暂未注册证书");
70+
}
71+
else {
6572
this.cert = response.data;
66-
console.log(this.cert);
67-
console.log(response.data);
6873
this.show = true;
6974
}
7075
})

src/components/request.vue

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<template>
22

33
<div>
4+
<el-row justify="center">
5+
<el-button @click="download">下载CSR制作工具</el-button>
6+
</el-row>
47
<el-form ref="form" :model="form" label-width="120px">
58
<el-form-item label="CSR">
69
<el-input v-model="form.csr" type="textarea" placeholder="请将csr文件内容粘贴于此"></el-input>
@@ -13,6 +16,7 @@
1316
<div class="radius" v-show="show">
1417
{{cert}}
1518
</div>
19+
1620
</div>
1721
</template>
1822

@@ -31,7 +35,8 @@ export default {
3135
3236
},
3337
cert: '',
34-
show: false
38+
show: false,
39+
serial: '',
3540
}
3641
},
3742
methods: {
@@ -46,14 +51,19 @@ export default {
4651
withCredentials: true
4752
}
4853
).then((response) => {
49-
if (response.data.error == 1) {
54+
if (response.data.error == 2) {
5055
msg.msFail("您已经拥有公钥文件");
51-
this.show = true;
52-
} else {
53-
this.cert = response.data.cert;
56+
// this.show = true;
57+
} else if (response.data.error == 1) {
58+
msg.msFail("证书格式不正确");
59+
}else {
60+
msg.msSuccess("申请成功 ");
5461
}
5562
})
5663
64+
},
65+
download() {
66+
window.location = location.origin + ":8000/main.zip";
5767
}
5868
}
5969
}

src/components/revoke.vue

+55-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
11
<template>
2-
<el-button>确定</el-button>
3-
</template>
2+
<el-row>
3+
<el-col :span="2" :offset="8" class="left">
4+
指定序列号
5+
</el-col>
6+
<el-col :span="4">
7+
<el-input v-model="serial"> </el-input>
8+
</el-col>
9+
<el-col :span="2" >
10+
<el-button @click="submit">撤销</el-button>
11+
</el-col>
12+
</el-row>
13+
</template>
14+
15+
<script>
16+
import axios from 'axios';
17+
import Cookies from 'js-cookie';
18+
import msg from '../js/msg';
19+
const url = location.origin + "/ca/revoke";
20+
21+
export default {
22+
name: "revoke",
23+
data() {
24+
return {
25+
serial: ''
26+
}
27+
},
28+
methods: {
29+
submit() {
30+
axios.post(url, {"serial": this.serial}, {
31+
headers: {
32+
"X-CSRF-TOKEN": Cookies.get("X-CSRF-TOKEN"),
33+
},
34+
withCredentials: true
35+
}).then((response) => {
36+
const error_code = response.data.error;
37+
if (error_code == 0) {
38+
msg.msSuccess("撤销成功");
39+
}
40+
if (error_code == 1) {
41+
msg.msFail("只有管理员才能撤销他人的证书");
42+
}
43+
if (error_code == 2) {
44+
msg.msFail("没有查询到目的证书")
45+
}
46+
}).catch(()=>{
47+
msg.msFail("网络错误");
48+
})
49+
}
50+
}
51+
}
52+
</script>
53+
54+
<style scoped>
55+
56+
</style>

src/components/userinfo.vue

+41-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,49 @@
11
<template>
2-
<div>
3-
用户信息
4-
</div>
2+
<el-row>
3+
<el-descriptions
4+
direction="vertical"
5+
border
6+
:column="1"
7+
style="width: 100%;"
8+
>
9+
<el-descriptions-item label="用户名">{{username}}</el-descriptions-item>
10+
<el-descriptions-item label="证书编号">{{serial}}</el-descriptions-item>
11+
<el-descriptions-item label="用户身份">{{role}}</el-descriptions-item>
12+
</el-descriptions>
13+
14+
</el-row>
515
</template>
616

717
<script>
18+
import axios from 'axios';
19+
import msg from '../js/msg';
20+
import Cookies from 'js-cookie'
21+
const url = location.origin + "/ca/usrinfo";
822
export default {
9-
23+
name: "userinfo",
24+
data() {
25+
return {
26+
username: '',
27+
serial: '',
28+
role: ''
29+
}
30+
},
31+
created() {
32+
axios.post(url, {}, {
33+
headers: {
34+
"X-CSRF-TOKEN": Cookies.get("X-CSRF-TOKEN"),
35+
},
36+
withCredentials: true
37+
}).then((response) => {
38+
const resp = response.data;
39+
this.username = resp.username;
40+
this.serial = resp.serial;
41+
this.role = resp.role;
42+
console.log(response.data);
43+
}).catch(()=>{
44+
msg.msFail("网络错误");
45+
})
46+
}
1047
}
1148
</script>
1249

src/views/test.vue

+4-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<script>
1414
//import aes from '../js/crypt.js';
15-
//import axios from 'axios';
15+
import axios from 'axios';
1616
import g from '../components/Global.vue';
1717
import jsencrypt from 'jsencrypt';
1818
//const url = location.origin + "/auth/";
@@ -24,14 +24,9 @@ export default {
2424
}
2525
},
2626
setup() {
27-
// const key = aes.b64parse(g.aes_key);
28-
// const iv = aes.b64parse(g.aes_iv);
29-
30-
//const ct = aes.encrypt(key, iv, "msg")
31-
32-
// axios.post(url + "echo", {"ct": ct}).then((response)=>{
33-
// console.log(aes.decrypt(key, iv, response.data.ct));
34-
// });
27+
axios.post("http://81.68.245.247:9000/bank.php").then((response)=>{
28+
console.log(response.data);
29+
})
3530
3631
var rsa_encryptor = new jsencrypt();
3732
rsa_encryptor.setPublicKey(g.rsa_pub);

0 commit comments

Comments
 (0)