diff --git a/app/pods/users/new/fail/route.js b/app/pods/users/new/fail/route.js deleted file mode 100644 index 26d9f31..0000000 --- a/app/pods/users/new/fail/route.js +++ /dev/null @@ -1,4 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Route.extend({ -}); diff --git a/app/pods/users/new/fail/template.hbs b/app/pods/users/new/fail/template.hbs deleted file mode 100644 index 534f7e0..0000000 --- a/app/pods/users/new/fail/template.hbs +++ /dev/null @@ -1 +0,0 @@ -

Failure

diff --git a/app/pods/users/new/success/route.js b/app/pods/users/new/success/route.js deleted file mode 100644 index 26d9f31..0000000 --- a/app/pods/users/new/success/route.js +++ /dev/null @@ -1,4 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Route.extend({ -}); diff --git a/app/pods/users/new/success/template.hbs b/app/pods/users/new/success/template.hbs deleted file mode 100644 index f5fbd3c..0000000 --- a/app/pods/users/new/success/template.hbs +++ /dev/null @@ -1 +0,0 @@ -

Success

diff --git a/app/pods/users/new/verify/route.js b/app/pods/users/new/verify/route.js index 26d9f31..3878445 100644 --- a/app/pods/users/new/verify/route.js +++ b/app/pods/users/new/verify/route.js @@ -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'); + } + }, + }); diff --git a/app/router.js b/app/router.js index 5fb53e3..3dc92aa 100644 --- a/app/router.js +++ b/app/router.js @@ -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' }); }); });