1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 23:59:47 +02:00

keycloak forgot password handling

This commit is contained in:
Harvey Kandola 2017-03-21 12:09:13 +00:00
parent 2c33c6443b
commit e5119dd243
3 changed files with 31 additions and 14 deletions

View file

@ -10,10 +10,27 @@
// https://documize.com
import Ember from 'ember';
import constants from '../../../utils/constants';
export default Ember.Route.extend({
appMeta: Ember.inject.service(),
beforeModel() {
if (this.get('appMeta.authProvider') === constants.AuthProvider.Keycloak) {
this.transitionTo('auth.login');
}
},
setupController(controller, model) {
controller.set('model', model);
controller.set('sayThanks', false);
}
},
activate() {
$('body').addClass('background-color-off-white');
},
deactivate() {
$('body').removeClass('background-color-off-white');
}
});

View file

@ -10,13 +10,13 @@
// https://documize.com
import Ember from 'ember';
// import constants from '../../../utils/constants';
import AuthProvider from '../../../mixins/auth';
export default Ember.Controller.extend({
export default Ember.Controller.extend(AuthProvider, {
appMeta: Ember.inject.service('app-meta'),
invalidCredentials: false,
session: Ember.inject.service('session'),
audit: Ember.inject.service('audit'),
invalidCredentials: false,
reset() {
this.setProperties({
@ -28,21 +28,19 @@ export default Ember.Controller.extend({
if (dbhash.length > 0 && dbhash !== "{{.DBhash}}") {
this.transitionToRoute('setup');
}
},
actions: {
login() {
let creds = this.getProperties('email', 'password');
this.get('session').authenticate('authenticator:documize', creds)
.then((response) => {
this.get('audit').record("logged-in");
this.transitionToRoute('folders');
return response;
}).catch(() => {
this.set('invalidCredentials', true);
});
this.get('session').authenticate('authenticator:documize', creds).then((response) => {
this.get('audit').record("logged-in");
this.transitionToRoute('folders');
return response;
}).catch(() => {
this.set('invalidCredentials', true);
});
}
}
});

View file

@ -18,7 +18,9 @@
<button type="submit" class="regular-button button-blue">Sign in</button>
<span class="{{unless invalidCredentials "hide"}} color-red margin-left-20">Invalid credentials</span>
</div>
{{#link-to 'auth.forgot'}}Forgot your password?{{/link-to}}
{{#if isAuthProviderDocumize}}
{{#link-to 'auth.forgot'}}Forgot your password?{{/link-to}}
{{/if}}
</form>
</div>
</div>