2017-03-24 20:45:52 -07:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
2017-11-05 21:15:13 -08:00
|
|
|
const { Controller, computed, get, setProperties, inject: { service } } = Ember;
|
2017-03-24 20:45:52 -07:00
|
|
|
|
|
|
|
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-11-05 21:15:13 -08:00
|
|
|
const { username, password } = this.getProperties(['username', 'password']);
|
2017-03-24 20:45:52 -07:00
|
|
|
|
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-11-05 21:15:13 -08:00
|
|
|
.catch(({ responseText = 'Bad Credentials' }) => setProperties(this, { errorMessage: responseText }));
|
2017-03-24 20:45:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|