I just added torii and emberfire to my ember project. The issue is at this point any user with a google account can authenticate and use the app. I want to check the returned data for currentUser.email and only grant access to users with emails from 2 specific domains. I've read the docs and attempted changing the signin action with no luck. Not sure the best way to handle this.
index.hbs
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<h1 class="welcomeHeading">WELCOME TO UTILITY BELT</h1>
<div>
<p class="lead flash-msg"></p>
</div>
<div>
<span>Currently logged in as </span><br/>
<a class="btn btn-md btn-danger signout" >Sign out</a>
<a class="btn btn-danger btn-md">Click to Sign In </a>
</div>
</div>
</div>
</div>
application.js route file
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function() {
return this.get('session').fetch().catch(function() {
});
},
actions: {
signIn: function(provider) {
this.get('session').open('firebase', {
provider: provider
}).then(function(data) {
if(data.currentUser.email.indexOf('domain1') < 0 & data.currentUser.email.indexOf('domain2') < 0){
let correctDomain = false;
return correctDomain;
}else{
let correctDomain = true;
return correctDomain;
}
});
},
signOut: function() {
this.get('session').close();
},
}
});
Aucun commentaire:
Enregistrer un commentaire