Add permission levels for students/tutors/admins
This commit is contained in:
@@ -16,16 +16,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { demoAccounts } from '~/components/DemoInfoDialog.vue'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'HelpPage',
|
name: 'HelpPage',
|
||||||
layout ({ $auth }) {
|
layout ({ $auth }) {
|
||||||
// Ref: https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#currentuser
|
// Ref: https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#currentuser
|
||||||
// return $auth.currentUser.emailVerified ? 'default' : 'unverified'
|
return $auth.currentUser.emailVerified ? 'default' : 'unverified'
|
||||||
|
|
||||||
// TODO: For demo purposes only. Delete in production.
|
|
||||||
return $auth.currentUser.emailVerified || demoAccounts.includes($auth.currentUser.email) ? 'default' : 'unverified'
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -18,12 +18,20 @@ export default {
|
|||||||
// whenever the user's sign-in state changes.
|
// whenever the user's sign-in state changes.
|
||||||
onAuthStateChanged(this.$auth, (user) => {
|
onAuthStateChanged(this.$auth, (user) => {
|
||||||
this.$store.commit('initFirebase')
|
this.$store.commit('initFirebase')
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
// User is signed in; get user data from db, then redirect to main page (dashboard)
|
// User is signed in; get user data from db, then redirect to main page (dashboard)
|
||||||
this.getUser()
|
this.getUser()
|
||||||
|
|
||||||
|
// Get user claims
|
||||||
|
// Ref: https://firebase.google.com/docs/auth/admin/custom-claims
|
||||||
|
user.getIdTokenResult().then((idTokenResult) => {
|
||||||
|
this.$store.commit('setIdTokenResult', idTokenResult)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
// User is signed out; redirect to login page
|
// User is signed out; redirect to login page
|
||||||
this.$store.commit('setUser', null)
|
this.$store.commit('setUser', null)
|
||||||
|
this.$store.commit('setIdTokenResult', null)
|
||||||
this.$router.push({ name: 'login' })
|
this.$router.push({ name: 'login' })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user