This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/routes/new-topic.js.es6

21 lines
746 B
JavaScript

export default Discourse.Route.extend({
beforeModel: function(transition) {
const self = this;
if (Discourse.User.current()) {
// User is logged in
self.replaceWith('discovery.latest').then(function(e) {
if (self.controllerFor('navigation/default').get('canCreateTopic')) {
// User can create topic
Ember.run.next(function() {
e.send('createNewTopicViaParams', transition.queryParams.title, transition.queryParams.body, transition.queryParams.category_id, transition.queryParams.category);
});
}
});
} else {
// User is not logged in
self.session.set("shouldRedirectToUrl", window.location.href);
self.replaceWith('login');
}
}
});