修复用户名密码修改,diff视图滚动

This commit is contained in:
whyour 2021-03-21 11:57:00 +08:00
parent f03323e5d8
commit ecb5bb1718
6 changed files with 33 additions and 20 deletions

View File

@ -25,12 +25,12 @@ export default (app: Router) => {
config.secret as any, config.secret as any,
{ expiresIn: 60 * 60 * 24 * 7, algorithm: 'HS384' }, { expiresIn: 60 * 60 * 24 * 7, algorithm: 'HS384' },
); );
res.send({ err: 0, token }); res.send({ code: 200, token });
} else { } else {
res.send({ err: 1, msg: config.authError }); res.send({ code: 400, msg: config.authError });
} }
} else { } else {
res.send({ err: 1, msg: '请输入用户名密码!' }); res.send({ err: 400, msg: '请输入用户名密码!' });
} }
}); });
} catch (e) { } catch (e) {
@ -39,4 +39,20 @@ export default (app: Router) => {
} }
}, },
); );
route.post(
'/user',
async (req: Request, res: Response, next: NextFunction) => {
const logger: Logger = Container.get('logger');
try {
fs.writeFile(config.authConfigFile, JSON.stringify(req.body), (err) => {
if (err) console.log(err);
res.send({ code: 200, msg: '更新成功' });
});
} catch (e) {
logger.error('🔥 error: %o', e);
return next(e);
}
},
);
}; };

View File

@ -63,6 +63,7 @@
"react": "17.x", "react": "17.x",
"react-dom": "17.x", "react-dom": "17.x",
"typescript": "^4.1.2", "typescript": "^4.1.2",
"yorkie": "^2.0.0" "yorkie": "^2.0.0",
"ts-node": "^9.0.0"
} }
} }

View File

@ -88,10 +88,10 @@ function Git_PullScripts {
echo -e "更新scripts...\n" echo -e "更新scripts...\n"
cd ${ScriptsDir} cd ${ScriptsDir}
git fetch --all git fetch --all
git rm -f i-chenzhe* git rm -f --ignore-unmatch i-chenzhe*
git rm -f moposmall* git rm -f --ignore-unmatch moposmall*
git rm -f qq34347476* git rm -f --ignore-unmatch qq34347476*
git rm -f whyour* git rm -f --ignore-unmatch whyour*
git stash git stash
git pull git pull
ExitStatusScripts=$? ExitStatusScripts=$?

View File

@ -18,7 +18,7 @@ body {
overflow: auto; overflow: auto;
.ant-pro-page-container-children-content { .ant-pro-page-container-children-content {
overflow: auto; overflow: auto;
min-height: calc(100vh - 96px); height: calc(100vh - 96px);
background-color: #fff; background-color: #fff;
} }
} }

View File

@ -18,7 +18,7 @@ const Login = () => {
}, },
}) })
.then((data) => { .then((data) => {
if (data.err == 0) { if (data.code == 200) {
localStorage.setItem(config.authKey, data.token); localStorage.setItem(config.authKey, data.token);
history.push('/cookie'); history.push('/cookie');
} else { } else {

View File

@ -29,22 +29,18 @@ const Password = () => {
const handleOk = (values: any) => { const handleOk = (values: any) => {
request request
.post(`${config.apiPrefix}auth?t=${Date.now()}`, { .post(`${config.apiPrefix}user?t=${Date.now()}`, {
data: { data: {
username: values.username, username: values.username,
password: values.password, password: values.password,
}, },
}) })
.then((data) => { .then((data: any) => {
if (data.err == 0) { notification.success({
localStorage.setItem(config.authKey, 'true');
} else {
notification.open({
message: data.msg, message: data.msg,
}); });
}
}) })
.catch(function (error) { .catch((error: any) => {
console.log(error); console.log(error);
}); });
}; };