2017-03-24 20:45:52 -07:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
const {
|
|
|
|
Controller,
|
|
|
|
computed,
|
2017-03-26 00:56:19 -07:00
|
|
|
get,
|
2017-03-24 20:45:52 -07:00
|
|
|
setProperties,
|
2017-03-26 00:56:19 -07:00
|
|
|
inject: { service }
|
2017-03-24 20:45:52 -07:00
|
|
|
} = Ember;
|
|
|
|
|
|
|
|
export default Controller.extend({
|
|
|
|
session: service(),
|
|
|
|
|
|
|
|
username: computed.alias('name'),
|
|
|
|
|
|
|
|
password: computed.alias('pass'),
|
|
|
|
|
|
|
|
errorMessage: '',
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
/**
|
|
|
|
* Using the session service, authenticate using the custom ldap authenticator
|
|
|
|
*/
|
|
|
|
authenticateUser() {
|
2017-03-26 00:56:19 -07:00
|
|
|
const { username, password } = this.getProperties([
|
2017-03-24 20:45:52 -07:00
|
|
|
'username',
|
|
|
|
'password'
|
|
|
|
]);
|
|
|
|
|
2017-03-26 00:56:19 -07:00
|
|
|
get(this, 'session')
|
2017-03-24 20:45:52 -07:00
|
|
|
.authenticate('authenticator:custom-ldap', username, password)
|
2017-03-26 00:56:19 -07:00
|
|
|
.catch(({ responseText = 'Bad Credentials' }) =>
|
|
|
|
setProperties(this, { errorMessage: responseText }));
|
2017-03-24 20:45:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|