activate.js 801 B

12345678910111213141516171819202122232425262728293031
  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. loading: function() {
  15. this.get('page-title').setTitle(gettext('Activating account...'));
  16. return true;
  17. },
  18. error: function(reason) {
  19. if (reason.status === 404) {
  20. this.get('toast').error(reason.responseJSON.detail);
  21. return this.transitionTo('activation');
  22. }
  23. return true;
  24. }
  25. }
  26. });