harungo
harungo

Reputation: 219

onBeforeAction, wrong redirect

My routes file:

Router.map ->
    @route 'mainPage', path: '/'
    @route 'login', 
        path:'/admin/login'
        onBeforeAction: ->
            @redirect '/' if Meteor.user()
            @next()

class @AdminController extends RouteController
    layoutTemplate: 'AdminHead'
    onBeforeAction: ->
        @redirect 'login' unless Meteor.user()
        @next()

Router.route 'dashboard', 
        controller: 'AdminController'
        path: '/admin'
Router.route 'addArticle', 
        controller: 'AdminController'
        path: '/admin/addArticle'

It's should not redirect to login page after authorization, but it's redirects. What i do wrong?

Upvotes: 0

Views: 133

Answers (1)

AJ Acevedo
AJ Acevedo

Reputation: 1268

You can redirect if Meteor.user() or Meteor.loggingIn()

This way it wont redirect to the login page if the user is still logging in.

Meteor.logginIn()

Upvotes: 1

Related Questions