Merge branch 'master' into clostridium

* master:
  Clean up verification
  Update flash message
  Inject global var service in routes
This commit is contained in:
Matthew Dillon 2015-07-14 13:43:57 -08:00
commit cca97e7542
10 changed files with 45 additions and 20 deletions

View file

@ -8,6 +8,7 @@ var globals = Ember.Object.extend({
export function initialize(container, application) { export function initialize(container, application) {
application.register('service:globals', globals, {singleton: true}); application.register('service:globals', globals, {singleton: true});
application.inject('route', 'globals', 'service:globals');
application.inject('controller', 'globals', 'service:globals'); application.inject('controller', 'globals', 'service:globals');
application.inject('component', 'globals', 'service:globals'); application.inject('component', 'globals', 'service:globals');
application.inject('adapter', 'globals', 'service:globals'); application.inject('adapter', 'globals', 'service:globals');

View file

@ -10,10 +10,6 @@ export default Ember.Route.extend(ApplicationRouteMixin, {
}); });
}, },
didTransition: function() { },
this.get('flashMessages').clearMessages();
return true;
},
}
}); });

View file

@ -1 +1 @@
{{flash.message}} ✖ {{flash.message}}

View file

@ -44,7 +44,9 @@
<div class="view-wrap"> <div class="view-wrap">
{{#each flashMessages.queue as |flash|}} {{#each flashMessages.queue as |flash|}}
{{custom-flash-message flash=flash}} {{#flash-message flash=flash as |component flash|}}
{{custom-flash-message flash=flash}}
{{/flash-message}}
{{/each}} {{/each}}
{{yield}} {{yield}}
</div> </div>

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'; import Ember from 'ember';
export default Ember.Route.extend({ 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('users', function() {
this.route('new', function() { this.route('new', function() {
this.route('fail'); this.route('verify', { path: 'verify/:nonce' });
this.route('success');
this.route('verify', { path: ':nonce' });
}); });
}); });