diff options
Diffstat (limited to 'src/components/remote_user_resolver/remote_user_resolver.js')
| -rw-r--r-- | src/components/remote_user_resolver/remote_user_resolver.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/components/remote_user_resolver/remote_user_resolver.js b/src/components/remote_user_resolver/remote_user_resolver.js new file mode 100644 index 00000000..9b5e511e --- /dev/null +++ b/src/components/remote_user_resolver/remote_user_resolver.js @@ -0,0 +1,31 @@ +const RemoteUserResolver = { + data: () => ({ + error: false + }), + mounted () { + this.redirect() + }, + methods: { + redirect () { + const acct = this.$route.params.username + '@' + this.$route.params.hostname + this.$store.state.api.backendInteractor.fetchUser({ id: acct }) + .then((externalUser) => { + if (externalUser.error) { + this.error = true + } else { + this.$store.commit('addNewUsers', [externalUser]) + const id = externalUser.id + this.$router.replace({ + name: 'external-user-profile', + params: { id } + }) + } + }) + .catch(() => { + this.error = true + }) + } + } +} + +export default RemoteUserResolver |
