Differential / accounts-entry

Meteor sign up and sign in pages
http://github.differential.com/accounts-entry/
MIT License
305 stars 189 forks source link

Uncaught TypeError: Cannot read property 'call' of undefined #265

Open garrilla opened 10 years ago

garrilla commented 10 years ago

I have a simple template

<template name="data">
    {{#if currentUser}}
        <h1>Data</h1>
    {{else}}
        {{> _loginButtons}}<!---->
    {{/if}}
</template>

if not logged in it shows the login buttons, but also produces this error

Uncaught TypeError: Cannot read property 'call' of undefined entry.coffee:35
AccountsEntry.signInRequired entry.coffee:35
route.onBeforeAction route.js?98d6cd6efc47ce011469dd88429d368295c42cd7:22
RouteController.runHooks route_controller.js:155
(anonymous function) route_controller.js:287
Tracker.Computation._compute tracker.js:255
Tracker.Computation tracker.js:173
Tracker.autorun tracker.js:443
(anonymous function) route_controller.js:264
(anonymous function) route_controller.js:236
Tracker.Computation._compute tracker.js:255
Tracker.Computation tracker.js:173
Tracker.autorun tracker.js:443
Utils.extend._run route_controller.js:245
run router.js:300
RouteController._stopController route_controller.js:179
onStop route_controller.js:201
(anonymous function) tracker.js:197
Tracker.nonreactive tracker.js:469
Tracker.Computation.onInvalidate tracker.js:196
Utils.extend._stopController route_controller.js:206
IronRouter.run router.js:308
Utils.extend.run router.js:143
IronRouter.dispatch router.js:281
Utils.extend.go router.js:202
Utils.extend.onClick router.js:345
jQuery.event.dispatch jquery.js:4624
elemData.handle

Any advice or a fix?

mbabauer commented 10 years ago

I am also having this problem, but it appears to be in the coming from the onBeforeAction of my route. Stack on the client is:

Exception in defer callback: TypeError: Cannot read property 'call' of undefined at Object.AccountsEntry.signInRequired (http://localhost:3000/packages/joshowens:accounts-entry.js?f7e4d669676cae372c56343c0fe6547061be6257:97:21) at route.onBeforeAction (http://localhost:3000/routes.js?4370f03a4b11f72ee9334b8365abf1090d95834e:50:52) at RouteController.runHooks (http://localhost:3000/packages/iron:router.js?6b18ea50d8f8d2ce59b5781394220f6cb28cfe09:843:16) at http://localhost:3000/packages/iron:router.js?6b18ea50d8f8d2ce59b5781394220f6cb28cfe09:2299:14 at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36) at new Tracker.Computation (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:206:10) at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:476:11) at http://localhost:3000/packages/iron:router.js?6b18ea50d8f8d2ce59b5781394220f6cb28cfe09:2276:12 at http://localhost:3000/packages/iron:router.js?6b18ea50d8f8d2ce59b5781394220f6cb28cfe09:2248:21 at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36) debug.js:41

My route is defined as: this.route('admin', { path: '/admin', onBeforeAction: function() { AccountsEntry.signInRequired(this); } });

The result of going to /admin is that I get routed to /sign-in, but I get no "Sign In" button. Typing in the username/password and hitting enter does nothing (or at least seems to).

I am running Meteor 0.9.1.1, using only accounts-password and accounts-entry (plus whatever gets pulled in via dependencies on those packages).

mbabauer commented 10 years ago

Ok, so I got passed this problem. Basically, I change the route to look like this:

this.route('dashboard', { path: '/dashboard', onBeforeAction: function(pause) { AccountsEntry.signInRequired(this, pause); } });

Notice the onBeforeAction call, passing 'pause' as an option to the function, then passing it to AccountsEntry.signInRequired().

Still having an issue with long, though. Keep getting ">Login forbidden<" when I try to login, but this is for another bug...

lb- commented 10 years ago

Thanks @mbabauer that fix worked for me, was having similar issues.