Ignore unauthorized instance

This commit is contained in:
AkiraFukushima 2018-03-09 00:33:43 +09:00
parent fa3bc25d77
commit 1d8b696765
1 changed files with 6 additions and 3 deletions

View File

@ -12,10 +12,14 @@ export default class Authentication {
this.clientSecret = ''
}
getAuthorizationUrl (baseURL = 'https://mastodon.social') {
setOtherInstance (baseURL) {
this.baseURL = baseURL
this.clientId = ''
this.clientSecret = ''
}
getAuthorizationUrl (baseURL = 'https://mastodon.social') {
this.setOtherInstance(baseURL)
return Mastodon.createOAuthApp(this.baseURL + '/api/v1/apps', appName, scope)
.catch(err => console.error(err))
.then((res) => {
@ -54,10 +58,9 @@ export default class Authentication {
})
}
// TODO: ignore unauthorized records which does not have accessToken.
listInstances () {
return new Promise((resolve, reject) => {
this.db.find({}, (err, doc) => {
this.db.find({accessToken: { $ne: '' }}, (err, doc) => {
if (err) return reject(err)
if (empty(doc)) reject(new EmptyTokenError('empty'))
const instances = doc.map((e, i, array) => {