Commit 03d77545 authored by 孙谢炜's avatar 孙谢炜

增加登录检测、密码加密

parent 683f5f9b
......@@ -245,6 +245,7 @@
import { ref, watch } from 'vue';
import { reactive } from 'vue';
import axios from 'axios';
import CryptoJS from 'crypto-js';
const form = ref(null);
const password = ref(null);
......@@ -479,9 +480,14 @@ function info(title, text) {
dialog.value = true;
}
function md5Hash(password) {
return CryptoJS.MD5(password).toString();
}
function setUserinform() {
informLoading.value = true;
var user = { user_name: username1.value, user_password: password.value }
var user = { user_name: username1.value, user_password: password.value };
user.user_password = md5Hash(user.user_password);
if (user.user_name !== null || user.user_password !== null) {
axios.post('/api/setUserinform',
user
......@@ -490,11 +496,12 @@ function setUserinform() {
const data = response.data;
if (data.status == 'SUCCESS') {
info('修改成功!', "");
username.value = user.user_name;
// username.value = user.user_name;
}
else if (data.status == 'FAILED') {
info('用户名已存在!', "");
}
refresh();
})
.catch(function (error) {
console.log(error);
......
......@@ -46,6 +46,20 @@ const tab = ref(null)
</v-app>
</template>
<script>
import { ref } from 'vue';
import { reactive } from 'vue';
import axios from 'axios';
axios.get('/api/currentUser',)
.then(function(response){
const data = response.data;
if (data.status === "SUCCESS"){
window.location.href = '/main.html';
}
})
</script>
<style>
.main-card{
width: 300px;
......
......@@ -19,9 +19,9 @@
<template v-slot:item.realname="{ item }">
<p v-if="item.user_realname" style="width:50px">{{ item.user_realname }}</p>
</template>
<template v-slot:item.password="{ item }">
<!-- <template v-slot:item.password="{ item }">
<p v-if="item.user_password" style="width:50px">{{ item.user_password }}</p>
</template>
</template> -->
<template v-slot:item.is_member="{ item }">
<p v-if="item.user_is_member" style="width:50px">{{ item.user_is_member }}</p>
</template>
......@@ -44,8 +44,8 @@
color="indigo" label="用户名"></v-text-field>
<v-text-field v-model="selectUser.user_realname" :rules="[rules.usrname]" variant="filled"
color="indigo" label="姓名"></v-text-field>
<v-text-field v-model="selectUser.user_password" :rules="[rules.password]" variant="filled"
color="indigo" label="密码"></v-text-field>
<v-text-field v-model="user_password" :rules="[rules.password]" variant="filled"
color="indigo" label="修改密码"></v-text-field>
<v-select v-model="selectUser.is_member" :rules="[rules.su]" :items="['是', '否']"
variant="filled" color="indigo" label="会员"></v-select>
<v-select v-model="selectUser.is_su" :rules="[rules.member]" :items="['是', '否']"
......@@ -78,6 +78,7 @@ import { ref } from 'vue';
import { reactive } from 'vue';
// import { computed } from 'vue';
import axios from 'axios';
import CryptoJS from 'crypto-js';
const search = ref('');
// const actions_text = ref('');
......@@ -85,7 +86,7 @@ const headers = reactive([
{ title: 'ID', key: 'userid' },
{ title: '用户名', key: 'username' },
{ title: '姓名', key: 'realname' },
{ title: '密码', key: 'password' },
// { title: '密码', key: 'password' },
{ title: '会员', key: 'is_member' },
{ title: '管理员', key: 'is_su' },
{ title: '编辑', key: 'actions' },
......@@ -120,6 +121,7 @@ const selectUser = ref({
is_member: '',
is_su: '',
});
const user_password = ref('');
const cardtitle = ref(null);
const cardtext = ref(null);
......@@ -175,6 +177,10 @@ function editUser(item) {
selectUser.value = item;
}
function md5Hash(password) {
return CryptoJS.MD5(password).toString();
}
function changeUser() {
userLoading.value = true;
if (selectUser.value.is_member === '是'){
......@@ -189,6 +195,7 @@ function changeUser() {
if (selectUser.value.is_su === '否'){
selectUser.value.user_is_su = false
}
selectUser.value.user_password = md5Hash(user_password.value); // 使用MD5进行前端哈希处理
axios.post('/api/userManage', selectUser.value)
.then(function (response) {
const data1 = response.data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment