| | |
| | | export default [ |
| | | { |
| | | path: '/', |
| | | redirect: '/system/user', |
| | | redirect: '/home', |
| | | }, |
| | | { |
| | | path: '/user', |
| | |
| | | ], |
| | | }, |
| | | { |
| | | path: '/welcome', |
| | | name: 'welcome', |
| | | path: '/home', |
| | | name: 'home', |
| | | icon: 'smile', |
| | | component: './Welcome', |
| | | component: './home', |
| | | }, |
| | | { |
| | | path: '*', |
| | |
| | | const [form] = Form.useForm(); |
| | | const [loginType, setLoginType] = useState('account'); |
| | | const [status, setStatus] = useState(200); |
| | | const [errDesc, setErrDesc] = useState(''); |
| | | const [rememberMe, setRememberMe] = useState(() => { |
| | | const storedValue = localStorage.getItem('rememberMe'); |
| | | return storedValue !== null ? JSON.parse(storedValue) : true; |
| | |
| | | return; |
| | | } |
| | | setStatus(r.code); |
| | | setErrDesc(r.msg); |
| | | } catch (error) { |
| | | console.log(error); |
| | | message.error(intl.formatMessage({ |
| | |
| | | )} |
| | | {status !== 200 && loginType === 'account' && ( |
| | | <LoginMessage |
| | | content={'账户或密码错误'} |
| | | content={errDesc} |
| | | /> |
| | | )} |
| | | {loginType === 'phone' && ( |
| | |
| | | import { useModel } from '@umijs/max'; |
| | | import Http from '@/utils/http'; |
| | | |
| | | const resetPwd = async (val) => { |
| | | const hide = message.loading('正在更新'); |
| | | try { |
| | | const resp = await Http.doPost('api/user/update', val); |
| | | if (resp.code === 200) { |
| | | message.success('更新成功'); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error('配置失败请重试!'); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const SecurityView = () => { |
| | | const [form] = Form.useForm(); |
| | | const { initialState } = useModel('@@initialState'); |
| | | const { currentUser } = initialState || {}; |
| | | |
| | | const handleFinish = (values) => { |
| | | console.log(values); |
| | | resetPwd({...values, userId: currentUser.id}); |
| | | } |
| | | |
| | | return ( |
| | |
| | | required: true, |
| | | message: '请输入新密码!', |
| | | }, |
| | | { |
| | | validator(_, value) { |
| | | if (value.length >= 4 && value.length <= 16) { |
| | | return Promise.resolve(); |
| | | } |
| | | return Promise.reject(new Error('新密码必须是4到16个字符!')); |
| | | }, |
| | | }, |
| | | ]} |
| | | /> |
| | | <ProFormText.Password |
| | |
| | | required: true, |
| | | message: '请再次输入新密码!', |
| | | }, |
| | | { |
| | | validator(_, value) { |
| | | if (form.getFieldValue('newPwd') === value) return Promise.resolve(); |
| | | return Promise.reject(new Error('两次输入的密码不相符!')); |
| | | } |
| | | } |
| | | ]} |
| | | /> |
| | | </ProForm> |
New file |
| | |
| | | |
| | | const Home = () => { |
| | | return ( |
| | | <> |
| | | <h1>Home</h1> |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | export default Home; |
| | |
| | | import com.zy.asrs.wcs.common.domain.BaseParam; |
| | | import com.zy.asrs.wcs.common.domain.KeyValVo; |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.system.controller.param.ResetPwdParam; |
| | | import com.zy.asrs.wcs.system.entity.User; |
| | | import com.zy.asrs.wcs.system.entity.UserRole; |
| | | import com.zy.asrs.wcs.system.service.UserRoleService; |
| | |
| | | @PreAuthorize("hasAuthority('system:user:update')") |
| | | @OperationLog("重置密码") |
| | | @PostMapping("/user/reset/pwd") |
| | | public R resetPwd(@RequestBody User user) { |
| | | if (!Cools.isEmpty(user.getPassword())) { |
| | | user.setPassword(userService.encodePassword(user.getPassword())); |
| | | public R resetPwd(@RequestBody ResetPwdParam param) { |
| | | User user = userService.getById(param.getId()); |
| | | if (!Cools.isEmpty(param.getOldPwd())) { |
| | | |
| | | } |
| | | if (!Cools.isEmpty(param.getPassword())) { |
| | | user.setPassword(userService.encodePassword(param.getPassword())); |
| | | } |
| | | user.setUpdateBy(getLoginUserId()); |
| | | user.setUpdateTime(new Date()); |
New file |
| | |
| | | package com.zy.asrs.wcs.system.controller.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2/28/2024 |
| | | */ |
| | | @Data |
| | | public class ResetPwdParam { |
| | | |
| | | private Long id; |
| | | |
| | | private String oldPwd; |
| | | |
| | | private String password; |
| | | |
| | | } |