Если текущий пользователь — foe@gmail.com или не john@gmail.com, файл все равно загружается.
Я ожидая, что текущий адрес электронной почты пользователя совпадает с файлом john@gmail.com, в противном случае он не будет загружен. В моем FileUpload.vue:
Upload Files
import { emitter, FILE_UPLOAD_STARTED, showErrorDialog } from "@/event-bus.js";
import { MenuItem } from "@headlessui/vue";
import axios from 'axios';
export default {
components: {
MenuItem
},
data() {
return {
userEmail: '',
showUploadButton: false,
errorFetchingEmail: false
};
},
mounted() {
this.fetchUserEmail();
},
methods: {
fetchUserEmail() {
axios.get('/api/user')
.then(response => {
this.userEmail = response.data.email;
if(this.userEmail === 'john@gmail.com'){
this.showUploadButton = true;
}
})
.catch(error => {
console.error('Error fetching user email:', error);
this.errorFetchingEmail = true;
});
},
onChange(ev) {
if (this.userEmail === 'john@gmail.com' && this.showUploadButton === true) {
emitter.emit(FILE_UPLOAD_STARTED, ev.target.files);
} else {
showErrorDialog("File upload not allowed for this user.");
}
}
}
};
И мой api.php, когда я загружаю файл как john@gmail.com, появляется ошибка «Загрузка файла не разрешена для этого пользователя». показывает и Ошибка получения электронной почты пользователя...... показывает
Подробнее здесь: https://stackoverflow.com/questions/787 ... s-email-ma