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