Skip to content

Instantly share code, notes, and snippets.

@ellismarte ellismarte/adsfasd.js Secret
Created Oct 3, 2016

Embed
What would you like to do?
constructor($scope, $state, auth, datastore, $rootScope, $http){
this.scope = $scope
this.scope.auth = auth;
this.$state = $state;
this.datastore = datastore;
this.rootScope = $rootScope;
this.http = $http;
this.config = {"withCredentials": true, "Access-Control-Allow-Origin": true}
this.scope.account = '';
this.scope.username = '';
this.scope.password = '';
this.scope.loggedIn = datastore.retrieve('loggedin') || false;
$rootScope.$on('loggedin', (event, value) => {
this.scope.loggedIn = value;
})
}
login(){
var accountAndUser = this.scope.username.split(".")
this.scope.account = accountAndUser[0]
this.scope.username = accountAndUser[1]
var body = {account: this.scope.account, username: this.scope.username, password: this.scope.password}
this.http.post("http://192.168.99.100:3000" + "/accounts/v1/authenticate", JSON.stringify(body), this.config)
.then((response) => {
this.handleSuccessfulLogin();
}, (err) => {
this.handleUnsuccessfulLogin(err.data.message)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.