diff --git a/libs/actions.js b/libs/actions.js index a024ca4..54b7354 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -161,9 +161,10 @@ module.exports = ({ assert(token, 'token required') const { userid } = await tokens.get(token) - const { type } = await users.get(providerid) + const provider = await users.get(providerid) + assert(provider.userid !== userid, 'You cannot subscribe to this provider.') assert( - type === 'provider', + provider.type === 'provider', 'You may only subscribe to provider accounts.' ) diff --git a/models/users.js b/models/users.js index f1cc7d7..5196897 100644 --- a/models/users.js +++ b/models/users.js @@ -35,7 +35,7 @@ module.exports = async con => { .coerceTo('array') return table.run(q) }, - async create(username, type, meta = {}) { + async create(username, type = 'user', meta = {}) { assert(username, 'username required') username = username.toLowerCase() const u = await table.hasBy('username', username)