Ok, managed to find a solution. Looks a bit overengineered, but it works:
<script>
import {defineComponent} from "vue";
import Moralis from "moralis";
import {mapGetters} from "vuex";
export default defineComponent ({
computed: {
...mapGetters('user', ['user']),
},
mounted() {
setInterval(async () => {
const emailVerified = await this.emailVerifiedLookup();
console.log('Email Verified: ', emailVerified);
}, 5000)
},
methods: {
async emailVerifiedLookup() {
const user = await Moralis.User.current();
const query = new Moralis.Query(user);
query.equalTo("objectId", this.user.id);
const response = await query.first();
return response.get('emailVerified');
}
}
})
</script>
I’m using Vue.js and vuex store to get the current user from the state of the app. However the solution is within async emailVerifiedLookup()
function.
But besically what is going on is you have to query for the current user. As just calling user.get('emailVerified')
doesn’t perform what we need. It think it just calles an object inside the session - that’s why it doesn’t update fields from the DB.
Once you have the current user as a responce you can get any field you want!