1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-03 17:28:28 +09:00

[API] Implement disconnect/twitter

This commit is contained in:
syuilo 2017-01-21 19:26:45 +09:00
parent 651effe6d9
commit cd6b681748

View File

@ -9,6 +9,25 @@ import event from '../event';
import config from '../../conf';
module.exports = (app: express.Application) => {
app.get('/disconnect/twitter', async (req, res): Promise<any> => {
if (res.locals.user == null) return res.send('plz signin');
const user = await User.findOneAndUpdate({
token: res.locals.user
}, {
$unset: {
twitter: ''
}
});
res.send(`Twitterの連携を解除しました :v:`);
// Publish i updated event
event(user._id, 'i_updated', await serialize(user, user, {
detail: true,
includeSecrets: true
}));
});
if (config.twitter == null) {
app.get('/connect/twitter', (req, res) => {
res.send('現在Twitterへ接続できません');