Skip to content

Instantly share code, notes, and snippets.

@zxqx
Created April 23, 2015 23:05
Show Gist options
  • Save zxqx/ff5817d6842caa932d78 to your computer and use it in GitHub Desktop.
Save zxqx/ff5817d6842caa932d78 to your computer and use it in GitHub Desktop.
/**
* Authenticate a user
*/
export default class Auth
{
constructor($http, envSettings)
{
this.$http = $http;
this.envSettings = envSettings;
}
async authenticate(username:string, password:string): Promise<void>
{
let env = await this.envSettings.get();
let baseURI = env.baseURI;
try {
let res = await this.$http.post(`${baseURI}/api/login`,
{ username: username, password: password });
console.log('Successfully logged in');
}
catch(e) {
console.log(e.data.error);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment