Refactor user lockout/pw reset

This commit is contained in:
Matthew Dillon 2015-11-10 09:22:35 -07:00
parent ec597cd419
commit 079b2c59f6
5 changed files with 49 additions and 32 deletions

View file

@ -1,15 +1,18 @@
import Ember from 'ember'; import Ember from 'ember';
import ajaxRequest from '../../../utils/ajax-request'; import ajaxRequest from '../../../utils/ajax-request';
export default Ember.Controller.extend({ const { Controller, inject: { service } } = Ember;
session: Ember.inject.service('session'),
export default Controller.extend({
session: service(),
globals: service(),
actions: { actions: {
save: function() { submit: function(email) {
let url = `${this.get('globals.apiURL')}/api/${this.get('globals.genus')}/users/lockout`; const url = `${this.get('globals.apiURL')}/api/${this.get('globals.genus')}/users/lockout`;
let options = { const options = {
method: 'POST', method: 'POST',
data: { email: this.get('email') }, data: { email: email },
}; };
ajaxRequest(url, options, this.get('session')); ajaxRequest(url, options, this.get('session'));
this.transitionToRoute('login'); this.transitionToRoute('login');

View file

@ -0,0 +1,18 @@
import Ember from 'ember';
const { Component } = Ember;
export default Component.extend({
email: null,
"on-submit": null,
actions: {
save: function() {
return this.attrs["on-submit"](this.get('email'));
},
emailDidChange: function(value) {
this.set('email', value);
},
}
});

View file

@ -0,0 +1,18 @@
<div class="grid-1">
<div class="span-1">
<fieldset>
<legend>Account Lockout/Password Reset</legend>
<form {{action 'save' on='submit'}}>
<ul>
<li>
<label>Email</label>
{{one-way-input type="text" class="email" value=email update=(action "emailDidChange")}}
</li>
<li>
<button type="submit" class="button-green smaller">Submit</button>
</li>
</ul>
</form>
</fieldset>
</div>
</div>

View file

@ -1,8 +0,0 @@
import Ember from 'ember';
export default Ember.Route.extend({
deactivate: function() {
this.controller.set('email', null);
},
});

View file

@ -1,18 +1,4 @@
<div class="grid-1"> {{
<div class="span-1"> users/requestlockouthelp/lockout-form
<fieldset> on-submit=(action "submit")
<legend>Account Lockout/Password Reset</legend> }}
<form {{action 'save' on='submit'}}>
<ul>
<li>
<label>Email</label>
{{input value=email}}
</li>
<li>
<button type="submit" class="button-green smaller">Submit</button>
</li>
</ul>
</form>
</fieldset>
</div>
</div>