Add updateChat function in api
parent
190e61557e
commit
2beffa46fb
|
@ -33,6 +33,10 @@ async function update(fields: object){
|
|||
await db.query('UPDATE users,user_meta SET'+qs+' WHERE users.username='+db.raw.escape(fields['name'])+' AND user_meta.username='+db.raw.escape(fields['name']));
|
||||
return {"success":""};
|
||||
}
|
||||
async function updateChat(fields: object){
|
||||
await db.query('UPDATE chat_integration SET xmpp='+db.raw.escape(fields['xmpp'])+', discord='+db.raw.escape(fields['discord'])+', irc='+db.raw.escape(fields['irc'])+', twitch='+db.raw.escape(fields['twitch'])+' WHERE username='+db.raw.escape(fields['name']));
|
||||
return {"success":""};
|
||||
}
|
||||
|
||||
async function changepwd(name: string, password: string, newpwd: string){
|
||||
if(!name || !password || !newpwd) return {"error":"Insufficient parameters"};
|
||||
|
@ -56,4 +60,4 @@ async function login(name: string, password: string){
|
|||
return false;
|
||||
}
|
||||
|
||||
export { register, update, changepwd, changesk, login };
|
||||
export { register, update, changepwd, changesk, login, updateChat };
|
22
src/http.ts
22
src/http.ts
|
@ -181,6 +181,28 @@ async function initAPI() {
|
|||
res.send(result);
|
||||
});*/
|
||||
});
|
||||
app.post('/api/user/update/chat', (req, res) => {
|
||||
validToken(req.cookies.Authorization).then((t) => {
|
||||
if(t) {
|
||||
return api.updateChat({name: t['username'],
|
||||
discord: "discord" in req.body ? req.body.discord : false,
|
||||
xmpp: "xmpp" in req.body ? req.body.xmpp : false,
|
||||
twitch: "twitch" in req.body ? req.body.twitch : false,
|
||||
irc: "irc" in req.body ? req.body.irc : false,
|
||||
}).then((r) => {
|
||||
res.send(r);
|
||||
return;
|
||||
});
|
||||
}
|
||||
else {
|
||||
res.send('{"error":"invalid token"}');
|
||||
return;
|
||||
}
|
||||
});
|
||||
/*api.update(req.body.username, req.body.password, req.body.title, req.body.bio, req.body.record).then((result) => {
|
||||
res.send(result);
|
||||
});*/
|
||||
});
|
||||
app.post('/api/user/password', (req, res) => {
|
||||
validToken(req.cookies.Authorization).then((t) => {
|
||||
if(t) {
|
||||
|
|
Reference in New Issue