auth-component.js
596 Bytes
export default {
name: 'AuthComponent',
props: {
tag: String,
auth: {
type: Boolean,
default: true
}
},
methods: {
async onClick() {
if (!this.auth) {
return this.$emit('click');
}
const user = await this.$sdk.getUser();
if (user && user.uid) {
this.$emit('click', {uid: user.uid});
} else {
this.$emit('cancel');
this.$sdk.goLogin();
}
}
},
render(h) {
return h(this.tag || 'div', {
on: {
click: this.onClick.bind(this)
}
}, this.$slots.default);
}
};