mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-23 17:45:12 +00:00
[API] Implement disconnect/twitter
This commit is contained in:
parent
651effe6d9
commit
cd6b681748
1 changed files with 19 additions and 0 deletions
|
@ -9,6 +9,25 @@ import event from '../event';
|
||||||
import config from '../../conf';
|
import config from '../../conf';
|
||||||
|
|
||||||
module.exports = (app: express.Application) => {
|
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) {
|
if (config.twitter == null) {
|
||||||
app.get('/connect/twitter', (req, res) => {
|
app.get('/connect/twitter', (req, res) => {
|
||||||
res.send('現在Twitterへ接続できません');
|
res.send('現在Twitterへ接続できません');
|
||||||
|
|
Loading…
Reference in a new issue