2020-11-02 10:31:05 -08:00
|
|
|
<template>
|
|
|
|
<div class="d-flex flex-column flex-md-row justify-content-between align-items-center">
|
|
|
|
<span class="my-2">
|
|
|
|
<Icon :v="providerOptions.icon || provider" set="b"/>
|
|
|
|
{{ providerOptions.name }}
|
|
|
|
</span>
|
|
|
|
<span v-if="connection === undefined">
|
2021-12-12 15:30:55 -08:00
|
|
|
<form :action="`${homeUrl}/api/user/social-redirect/${provider}/${config.locale}`"
|
|
|
|
v-if="providerOptions.instanceRequired" class="input-group input-group-sm">
|
|
|
|
<input type="text" name="instance" class="form-control"
|
|
|
|
:placeholder="$t('user.login.instancePlaceholder')">
|
|
|
|
<button type="submit" class="btn btn-outline-secondary">
|
|
|
|
<Icon v="link"/>
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
<a v-else :href="`${homeUrl}/api/user/social-redirect/${provider}/${config.locale}`" class="badge bg-light text-dark border">
|
2020-11-02 10:31:05 -08:00
|
|
|
<Icon v="link"/>
|
|
|
|
<T>user.socialConnection.connect</T>
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
<span v-else class="text-center">
|
|
|
|
<span class="mr-3">
|
2020-11-02 12:12:15 -08:00
|
|
|
<a href="#" @click.prevent="$emit('setAvatar', provider)">
|
|
|
|
<Avatar :src="connection.avatar" :user="$user()" dsize="2rem"/>
|
|
|
|
</a>
|
2020-11-02 10:31:05 -08:00
|
|
|
{{connection.name}}
|
|
|
|
</span>
|
|
|
|
<br class="d-md-none"/>
|
2021-12-12 15:30:55 -08:00
|
|
|
<a :href="`${homeUrl}/api/user/social-redirect/${provider}/${config.locale}` + (providerOptions.instanceRequired ? '?instance=' + connection.name.split('@')[1] : '')"
|
|
|
|
class="badge bg-light text-dark border">
|
2020-11-02 10:31:05 -08:00
|
|
|
<Icon v="sync"/>
|
|
|
|
<T>user.socialConnection.refresh</T>
|
|
|
|
</a>
|
|
|
|
<Spinner v-if="disconnecting"/>
|
2021-01-22 14:54:24 -08:00
|
|
|
<a v-else href="#" class="badge bg-light text-dark" @click.prevent="disconnect">
|
2020-11-02 10:31:05 -08:00
|
|
|
<Icon v="unlink"/>
|
|
|
|
<T>user.socialConnection.disconnect</T>
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
provider: { required: true },
|
|
|
|
providerOptions: { required: true },
|
|
|
|
connection: {},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
disconnecting: false,
|
2021-12-03 08:39:14 -08:00
|
|
|
homeUrl: process.env.HOME_URL,
|
2020-11-02 10:31:05 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async disconnect() {
|
|
|
|
await this.$confirm(this.$t('user.socialConnection.disconnectConfirm', {email: this.$user().email}), 'danger');
|
|
|
|
|
|
|
|
this.disconnecting = true;
|
2021-06-09 09:06:32 -07:00
|
|
|
try {
|
|
|
|
const response = await this.$post(`/user/social-connection/${this.provider}/disconnect`);
|
|
|
|
this.$emit('disconnected', response);
|
|
|
|
} finally {
|
|
|
|
this.disconnecting = false;
|
|
|
|
}
|
2020-11-02 10:31:05 -08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|