首页>代码>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";
    }

}
最近下载更多
ed8vid  LV4 3月21日
zdhsqnm  LV1 2月10日
LITIANYU084414  LV11 1月4日
微信网友_6248713511227392  LV11 2022年12月5日
jiangchen666888  LV1 2022年11月30日
1792461859  LV2 2022年11月15日
Anbname  LV1 2022年8月24日
Rachelzzz200  LV1 2022年6月23日
Fendabo  LV1 2022年6月20日
kingguang  LV8 2022年6月16日
最近浏览更多
hihhhh  LV4 11小时前
ed8vid  LV4 3月21日
1821985965 3月13日
暂无贡献等级
Wedssda 3月7日
暂无贡献等级
美丽hhhh  LV3 2月28日
dongandmin  LV6 2月27日
zdhsqnm  LV1 2月10日
LITIANYU084414  LV11 1月4日
qq1061521319  LV4 2022年12月18日
666ing  LV1 2022年12月16日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友