activate.js 766 B

123456789101112131415161718192021222324252627282930
  1. import MisagoRoute from 'misago/routes/misago';
  2. import ResetScroll from 'misago/mixins/reset-scroll';
  3. export default MisagoRoute.extend(ResetScroll, {
  4. model: function(params) {
  5. return this.rpc.ajax('activation/' + params.user_id + '/' + params.token + '/validate-token');
  6. },
  7. afterModel: function(model) {
  8. this.auth.openLoginModal();
  9. this.toast.success(model.detail);
  10. return this.transitionTo('index');
  11. },
  12. actions: {
  13. loading: function() {
  14. this.set('title', gettext('Activating account...'));
  15. return true;
  16. },
  17. error: function(reason) {
  18. if (reason.status === 404) {
  19. this.toast.error(reason.responseJSON.detail);
  20. return this.transitionTo('activation');
  21. }
  22. return true;
  23. }
  24. }
  25. });