activate.js 675 B

1234567891011121314151617181920212223242526
  1. import Ember from 'ember';
  2. import ResetScroll from 'misago/mixins/reset-scroll';
  3. import rpc from 'misago/utils/rpc';
  4. export default Ember.Route.extend(ResetScroll, {
  5. model: function(params) {
  6. return rpc('activation/' + params.user_id + '/' + params.token + '/validate-token/');
  7. },
  8. afterModel: function(model) {
  9. this.send('openLoginModal');
  10. this.get('toast').success(model.detail);
  11. return this.transitionTo('index');
  12. },
  13. actions: {
  14. error: function(reason) {
  15. if (reason.status === 404) {
  16. this.get('toast').error(reason.responseJSON.detail);
  17. return this.transitionTo('activation');
  18. }
  19. return true;
  20. }
  21. }
  22. });