首页>代码>基于(SpringMVC + Spring + Mybatis + Shiro + Bootstrap)开发的ssm教务后台管理系统>/Examination_System/src/main/java/com/system/controller/RestPasswordController.java
package com.system.controller;

import com.system.exception.CustomException;
import com.system.po.Userlogin;
import com.system.service.UserloginService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * Created by Jacey on 2017/7/6.
 */
@Controller
public class RestPasswordController {

    @Resource(name = "userloginServiceImpl")
    private UserloginService userloginService;

    // 本账户密码重置
    @RequestMapping(value = "/passwordRest", method = {RequestMethod.POST})
    public String passwordRest(String oldPassword, String password1) throws Exception {
        Subject subject = SecurityUtils.getSubject();
        String username = (String) subject.getPrincipal();

        Userlogin userlogin = userloginService.findByName(username);

        if (!oldPassword.equals(userlogin.getPassword())) {
            throw new CustomException("旧密码不正确");
        } else {
            userlogin.setPassword(password1);
            userloginService.updateByName(username, userlogin);
        }

        return "redirect:/logout";
    }

}
最近下载更多
zolscy  LV24 2024年11月29日
yangyang567  LV1 2024年3月8日
五折也挺好的  LV13 2023年7月12日
lds85930  LV11 2023年5月29日
qiangmin1223  LV12 2023年4月24日
wubinbin  LV11 2023年3月29日
ed8vid  LV4 2023年3月21日
ycx199422  LV6 2023年2月28日
dongandmin  LV8 2023年2月27日
levmar  LV12 2023年2月1日
最近浏览更多
SuZhuang 5月30日
暂无贡献等级
哪里的完整版  LV8 3月10日
ma406805131  LV19 2024年12月26日
暂无贡献等级
xmh064451 2024年7月21日
暂无贡献等级
谯桂生  LV2 2024年6月18日
GUANG001  LV1 2024年6月17日
微信网友_7035930581340160  LV1 2024年6月13日
美羊羊 2024年6月7日
暂无贡献等级
Ray_JJU 2024年6月7日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友