Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccountsTemplates.ensureSignedIn undefiend #38

Open
trsh opened this issue Apr 22, 2016 · 3 comments
Open

AccountsTemplates.ensureSignedIn undefiend #38

trsh opened this issue Apr 22, 2016 · 3 comments

Comments

@trsh
Copy link

trsh commented Apr 22, 2016

With newest builds AccountsTemplates.ensureSignedIn is undefined.

@emenoh
Copy link

emenoh commented May 17, 2016

Try this after adding packages as described in docs.

I put the below code blocks in my router.js file that is imported by imports/startup/client/index.js as described in guide.meteor.com application structure.

import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { Accounts } from 'meteor/useraccounts:semantic-ui';
import { AccountsTemplates } from 'meteor/useraccounts:core';

//your other template imports
import '../../ui/pages/admin/signin.js';

var public = FlowRouter.group({
//public route triggers, etc
})

var private = FlowRouter.group({
  triggersEnter: [AccountsTemplates.ensureSignedIn]
})

private.route('/admin', {
  action: function(params, queryParams) {
    BlazeLayout.render('MasterTemplate', { main: "Admin" });
  },
  name: 'Admin'
})

public.route('/sign-in', {
  action: function(params, queryParams) {
    BlazeLayout.render('MasterTemplate', { main: "SignIn" });
  },
  name: 'SignIn'
});

//more routes...

AccountsTemplates.configure({
    defaultLayoutType: 'blaze',
    defaultLayout: 'MasterLayout',
    //defaultTemplate: 'myCustomFullPageAtForm',
    defaultLayoutRegions: {},
    defaultContentRegion: 'main'
});


AccountsTemplates.configureRoute('signIn', {
    name: 'signin',
    path: '/sign-in',
    redirect: '/'
});

//end of router.js

Then in the signin template..

<template name="SignIn">
{{> fullPageAtForm}}
</template>

and in the signin.js

import { Template } from 'meteor/templating';
import './signin.html';

That should get you started. The trick is that this module 'extends' the useraccounts:core package, so by importing it, you also get the flow-router extensions (if you've added this package). I use Semantic UI for Blaze stuff, so I've included that in this example but I'm 99.9% sure any of the accounts-ui templating add ons will work the same.

@trsh
Copy link
Author

trsh commented May 17, 2016

This thing is like month old. I don't even remember why writing it :/

@emenoh
Copy link

emenoh commented May 17, 2016

Hmm not sure why you wrote it but I spent 2-3 hours working out how to get flow-router account-ui integration working properly using imports. So there it is for anyone who wants to find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants