vue-element添加修改密码弹窗
1.新建修改密码vue文件CgPwd.vue
代码如下:
<template>
<!-- 修改密码界面 -->
<el-dialog :title="$t('common.changePassword')" width="40%" :visible.sync="cgpwdVisible" :close-on-click-modal="false" :modal-append-to-body='false'>
<el-form :model="dataForm" label-width="80px" :rules="dataFormRules" ref="dataForm" :size="size"
label-position="right">
<el-form-item label="旧密码" prop="oldpassword">
<el-input v-model="dataForm.oldpassword" type="password" auto-complete="off"></el-input>
</el-form-item>
<el-form-item label="新密码" prop="newpassword">
<el-input v-model="dataForm.newpassword" type="password" auto-complete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" style="margin-top: 5px;">
<el-button :size="size" @click.native="cgpwdVisible = false">{{$t('action.cancel')}}</el-button>
<el-button :size="size" type="primary" @click.native="submitForm" :loading="editLoading">{{$t('action.submit')}}</el-button>
</div>
</el-dialog>
</template> <script>
import axios from 'axios';
export default {
data() {
return {
size: 'small',
cgpwdVisible: false, // 编辑界面是否显示
editLoading: false, //载入图标
//初始化数据
dataForm: {
oldpassword: '',
newpassword: ''
},
//设置属性
dataFormRules: {
oldpassword: [
{ required: true, message: '请输入旧密码', trigger: 'blur' }
],
newpassword: [
{ required: true, message: '请输入新密码', trigger: 'blur' }
]
},
//获取全局url
baseUrl: this.global.baseUrl
}
},
methods: {
// 设置可见性
setCgpwdVisible: function (cgpwdVisible) {
this.cgpwdVisible = cgpwdVisible
},
//mounted: 在这发起后端请求,拿回数据,配合路由钩子做一些事情 (dom渲染完成 组件挂载完成 )
mounted() { }
}
</script> <style scoped> </style>
2.修改原有密码修改button
<span class="main-operation-item">
<el-button size="small" icon="fa fa-key" @click="showCgpwdDialog"> 修改密码</el-button>
</span>
3.增加动态引用
<!--修改密码界面-->
<CgPwd ref="cgpwdDialog" @afterRestore="afterCgpwd"></CgPwd>
4.在原有vue文件script中进行修改
//引入Cgpwd.vue文件
import CgPwd from "@/views/Sys/CgPwd" export default {
...
//在components中添加CgPwd,这样<CgPwd>才不会报错
components:{
...
CgPwd
},
...
methods: {
...
//显示密码修改弹窗界面
showCgpwdDialog: function() {
this.$refs.cgpwdDialog.setCgpwdVisible(true)
},
...
},
mounted() {
}
}
5.添加路由
新建文件cgpwd.js
import axios from '../axios' /*
* 用户密码修改
*/ // 保存
export const pwdUpd = (data) => {
return axios({
url: '/user/pwdupd',
method: 'post',
data
})
}
6.在接口统一集成模块api.js中添加
import * as cgpwd from './moudules/cgpwd' export default {
...
cgpwd
}
7.在后台controller中添加代码
使用@RequestBody来接收body
/**
* 修改密码
* @return
*/
@RequestMapping(value="/pwdupd")
public String pwdupd(@RequestBody String body) {
return body;
}
8.添加权限例外
import com.vuebg.admin.security.JwtAuthenticationFilter;
import com.vuebg.admin.security.JwtAuthenticationProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler; /**
* Spring Security Config
* @author
* @date 2018-12-12
*/
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired
private UserDetailsService userDetailsService; @Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
// 使用自定义身份验证组件
auth.authenticationProvider(new JwtAuthenticationProvider(userDetailsService));
} /**
* 添加不需要进行权限验证的url
* @param http
* @throws Exception
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
// 禁用 csrf, 由于使用的是JWT,我们这里不需要csrf
http.cors().and().csrf().disable()
.authorizeRequests()
// 跨域预检请求
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
...//修改密码
.antMatchers("/user/pwdupd").permitAll()
// 其他所有请求需要身份认证
.anyRequest().authenticated();
// 退出登录处理器
http.logout().logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler());
// token验证过滤器
http.addFilterBefore(new JwtAuthenticationFilter(authenticationManager()), UsernamePasswordAuthenticationFilter.class);
} @Bean
@Override
public AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
} }
9.结果如下
vue-element添加修改密码弹窗的更多相关文章
- roundcute 添加修改密码插件
添加修改密码插件 现打开main.inc.php 文件,搜索“$rcmail_config['plugins']”,找到: // List of active plugins (in plugins/ ...
- vue element Admin - 修改浏览器标签名 + 添加tagView标签 +固定导航头部 + 添加侧边栏Logo
1 .修改浏览器标签名称: 修改浏览器标签名称在文件:\src\settings.js image.png 2 .修改固定头部Header和侧边栏 Logo: image.png 1)侧边栏文 ...
- exchang2010OWA主界面添加修改密码选项
原文链接:http://www.mamicode.com/info-detail-1444660.html exchange邮箱用户可以登录OWA修改密码,当AD用户密码过期或者重置密码勾选了“用户下 ...
- 学用MVC4做网站六后台管理:6.1.3管理员修改密码
6.1.3修改密码 需要两个action.一个是点击修改密码的链接要显示修改密码的分部视图(对话框形式):另一个是提交的处理action. 1.打开[AdministratorController]添 ...
- sharepoint修改密码
增加SharePoint2010修改域密码功能 前提SharePoint2010的用户基于AD的,因此修改密码是修改了AD的密码,当然也可以修改本机密码(非域的密码).这里我们讨论修改域密码.我们修改 ...
- 循序渐进VUE+Element 前端应用开发(24)--- 修改密码的前端界面和ABP后端设置处理
用户在系统登录后,一般会提供一个入口给当前用户更改当前的密码,其实更改密码操作是很简单的一个处理,不过本篇随笔主要是介绍结合前后端来实现这个操作,后端是基于ABP框架的,需要对密码的安全性进行一个设置 ...
- 打通前后端全栈开发node+vue进阶【课程学习系统项目实战详细讲解】(3):用户添加/修改/删除 vue表格组件 vue分页组件
第三章 建议学习时间8小时 总项目预计10章 学习方式:详细阅读,并手动实现相关代码(如果没有node和vue基础,请学习前面的vue和node基础博客[共10章] 演示地址:后台:demo ...
- Vue 两个字段联合校验典型例子--修改密码
1.前言 本文是前文<Vue Element-ui表单校验规则,你掌握了哪些?>针对多字段联合校验的典型应用. 在修改密码时,一般需要确认两次密码一致,涉及2个属性字段.类似的涉及 ...
- MVC5 网站开发之六 管理员 2、添加、删除、重置密码、修改密码、列表浏览
目录 奔跑吧,代码小哥! MVC5网站开发之一 总体概述 MVC5 网站开发之二 创建项目 MVC5 网站开发之三 数据存储层功能实现 MVC5 网站开发之四 业务逻辑层的架构和基本功能 MVC5 网 ...
随机推荐
- 【python】集合 list差集|并集|交集
两个list差集 list(set(b).difference(set(a))) # b中有而a中没有的 示例: a=[1,2,3] b=[2,3] list(set(a).difference(se ...
- C++拷贝构造函数心得
C++Primer作者提到拷贝构造函数调用的三种时机: 1. 当用一个类对象去初始化另外一个类对象(类似于 AClass aInstance = bInstance),这里不是调用赋值构造函数(也叫赋 ...
- wpf datagrid tooltip
<DataGridTemplateColumn Header="购方名称" Width="260" HeaderStyle="{StaticRe ...
- Activity启动流程(三)
这里对启动Activity过程中涉及到的ActivityStack.TaskRecord.ActivityRecord.ActivityStackSupervisor进行简单的分析,实际上一张时序图就 ...
- Matlab——程序设计
M文件 我们之前所做的运算————> 算式不太长,或想以交谈式方式进行运算 如果算式很长或是需要一再执行的算式————> 采用M文件的方式 [将指令及算式写成巨集程式然后储存成一个特别的文 ...
- 14.使用Crunch创建字典----Armitage扫描和利用----设置虚拟渗透测试实验室----proxychains最大匿名
使用Crunch创建字典 kali自带的字典 usr/share/wordlists cd Desktop mkdir wordlists cd wordlists/ crunch --help cr ...
- 【Linux开发】如何更改linux文件的拥有者及用户组(chown和chgrp)
本文整理自: http://blog.163.com/yanenshun@126/blog/static/128388169201203011157308/ http://ydlmlh.iteye.c ...
- 联想Z485安装64位ubantu
开始今天的正式写作之前不得不吐槽一下联想电脑,真的是很垃圾!联想Z485使用的是AMD的处理器,性能差的很,更让人不能忍的是,居然不能正常安装64位ubantu.这个情况让那些想在自己笔记电脑上安装T ...
- mysql日志信息查看与设置mysql-bin
查看 sql查询记录 日志是否开启 SHOW GLOBAL VARIABLES LIKE '%general_log%' 二进制日志 是否开启 SHOW GLOBAL VARIABLES LIKE ...
- java面向对象详细全面介绍
一.面向对象 1.面向过程与面向对象 POP与OOP都是一种思想,面向对象是相对于面向过程而言的.面向过程,强调的是功能行为,以函数为最小单位,考虑怎么做.面向对象,将功能封装进对象,强调具备了功能的 ...