2019-12-20 13:04:34 +01:00
|
|
|
<template>
|
2020-02-18 08:57:00 +01:00
|
|
|
<section class="section container hero is-fullheight">
|
|
|
|
<div class="hero-body">
|
|
|
|
<div class="container">
|
2020-06-05 15:20:53 +02:00
|
|
|
<div class="columns is-vcentered">
|
|
|
|
<div class="column has-text-centered">
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-button
|
|
|
|
type="is-primary"
|
|
|
|
size="is-medium"
|
|
|
|
tag="router-link"
|
|
|
|
:to="{ name: RouteName.LOGIN }"
|
|
|
|
>{{ $t("Login on {instance}", { instance: host }) }}</b-button
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
<vertical-divider :content="$t('Or')" />
|
|
|
|
<div class="column">
|
|
|
|
<subtitle>{{ $t("I have an account on another Mobilizon instance.") }}</subtitle>
|
|
|
|
<p>{{ $t("Other software may also support this.") }}</p>
|
|
|
|
<p>
|
|
|
|
{{ $t("We will redirect you to your instance in order to interact with this event") }}
|
|
|
|
</p>
|
|
|
|
<form @submit.prevent="redirectToInstance">
|
|
|
|
<b-field :label="$t('Your federated identity')">
|
|
|
|
<b-field>
|
|
|
|
<b-input
|
|
|
|
expanded
|
|
|
|
autocapitalize="none"
|
|
|
|
autocorrect="off"
|
|
|
|
v-model="remoteActorAddress"
|
|
|
|
:placeholder="$t('profile@instance')"
|
|
|
|
></b-input>
|
|
|
|
<p class="control">
|
|
|
|
<button class="button is-primary" type="submit">{{ $t("Go") }}</button>
|
|
|
|
</p>
|
|
|
|
</b-field>
|
|
|
|
</b-field>
|
|
|
|
</form>
|
|
|
|
</div>
|
2019-12-20 13:04:34 +01:00
|
|
|
</div>
|
2020-02-18 08:57:00 +01:00
|
|
|
<div class="has-text-centered">
|
|
|
|
<b-button tag="a" type="is-text" @click="$router.go(-1)">{{
|
|
|
|
$t("Back to previous page")
|
|
|
|
}}</b-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2019-12-20 13:04:34 +01:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
|
|
|
import VerticalDivider from "@/components/Utils/VerticalDivider.vue";
|
|
|
|
import Subtitle from "@/components/Utils/Subtitle.vue";
|
|
|
|
import RouteName from "../../router/name";
|
2019-12-20 13:04:34 +01:00
|
|
|
|
|
|
|
@Component({
|
2020-02-18 08:47:41 +01:00
|
|
|
components: { Subtitle, VerticalDivider },
|
2019-12-20 13:04:34 +01:00
|
|
|
})
|
|
|
|
export default class ParticipationWithAccount extends Vue {
|
|
|
|
@Prop({ type: String, required: true }) uuid!: string;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
remoteActorAddress = "";
|
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
RouteName = RouteName;
|
|
|
|
|
|
|
|
get host() {
|
|
|
|
return window.location.hostname;
|
|
|
|
}
|
|
|
|
|
|
|
|
get uri(): string {
|
2020-02-18 08:57:00 +01:00
|
|
|
return `${window.location.origin}${
|
|
|
|
this.$router.resolve({
|
|
|
|
name: RouteName.EVENT,
|
|
|
|
params: { uuid: this.uuid },
|
|
|
|
}).href
|
|
|
|
}`;
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async redirectToInstance() {
|
|
|
|
let res;
|
2020-02-18 08:57:00 +01:00
|
|
|
const [_, host] = (res = this.remoteActorAddress.split("@", 2));
|
2019-12-20 13:04:34 +01:00
|
|
|
const remoteInteractionURI = await this.webFingerFetch(host, this.remoteActorAddress);
|
|
|
|
window.open(remoteInteractionURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
private async webFingerFetch(hostname: string, identity: string): Promise<string> {
|
2020-02-18 08:57:00 +01:00
|
|
|
const scheme = process.env.NODE_ENV === "production" ? "https" : "http";
|
|
|
|
const data = await (
|
|
|
|
await fetch(`${scheme}://${hostname}/.well-known/webfinger?resource=acct:${identity}`)
|
|
|
|
).json();
|
2019-12-20 13:04:34 +01:00
|
|
|
if (data && Array.isArray(data.links)) {
|
2020-02-18 08:57:00 +01:00
|
|
|
const link: { template: string } = data.links.find(
|
|
|
|
(link: any) =>
|
|
|
|
link &&
|
|
|
|
typeof link.template === "string" &&
|
|
|
|
link.rel === "http://ostatus.org/schema/1.0/subscribe"
|
|
|
|
);
|
2019-12-20 13:04:34 +01:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
if (link && link.template.includes("{uri}")) {
|
|
|
|
return link.template.replace("{uri}", encodeURIComponent(this.uri));
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
throw new Error("No interaction path found in webfinger data");
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
</script>
|