Clean up verification

This commit is contained in:
Matthew Dillon 2015-07-14 13:43:40 -08:00
parent 6ce2fbe83b
commit e91a283680
6 changed files with 39 additions and 13 deletions

View file

@ -1,4 +0,0 @@
import Ember from 'ember';
export default Ember.Route.extend({
});

View file

@ -1 +0,0 @@
<h3>Failure</h3>

View file

@ -1,4 +0,0 @@
import Ember from 'ember';
export default Ember.Route.extend({
});

View file

@ -1 +0,0 @@
<h3>Success</h3>

View file

@ -1,4 +1,42 @@
import Ember from 'ember';
export default Ember.Route.extend({
apiURL: function() {
return this.get('globals.apiURL');
}.property(),
genus: function() {
return this.get('globals.genus');
}.property(),
model: function(params) {
let url = this.get('apiURL') + '/api/' + this.get('genus') + '/users/verify/' + params.nonce;
return new Ember.RSVP.Promise(function(resolve, reject) {
let options = {
success: function(data){
resolve(data);
},
error: function(jqXHR, status, error){
reject(jqXHR, status, error);
},
dataType: 'text json',
};
Ember.$.ajax(url, options);
});
},
afterModel: function(model/*, transition*/) {
this.get('flashMessages').success(model.msg);
this.transitionTo('login');
},
actions: {
error: function(error/*, transition*/) {
let err = Ember.$.parseJSON(error.responseText);
this.get('flashMessages').error(err.error);
this.transitionTo('login');
}
},
});

View file

@ -10,9 +10,7 @@ Router.map(function() {
this.route('users', function() {
this.route('new', function() {
this.route('fail');
this.route('success');
this.route('verify', { path: ':nonce' });
this.route('verify', { path: 'verify/:nonce' });
});
});