don't allow starring if not logged in

Signed-off-by: MiniDigger <admin@minidigger.me>
This commit is contained in:
MiniDigger 2020-10-08 17:38:20 +02:00
parent 5e491821c0
commit c65c6daa1d

View File

@ -78,6 +78,7 @@ export default {
}, },
methods: { methods: {
watch() { watch() {
if (!this.checkHasUser()) return;
this.value.watching = !this.value.watching; this.value.watching = !this.value.watching;
$.ajax({ $.ajax({
type: 'post', type: 'post',
@ -85,6 +86,7 @@ export default {
}); });
}, },
star() { star() {
if (!this.checkHasUser()) return;
this.value.starCount += this.starIncrement; this.value.starCount += this.starIncrement;
this.value.starred = this.starIncrement > 0; this.value.starred = this.starIncrement > 0;
$.ajax({ $.ajax({
@ -93,6 +95,14 @@ export default {
}); });
this.starIncrement *= -1; this.starIncrement *= -1;
}, },
checkHasUser() {
if (!this.hasUser) {
// TODO some alert or modal?
alert("Please login first");
return false;
}
return true;
}
}, },
created() { created() {
this.value.starred = this.isStarred; this.value.starred = this.isStarred;