require('/imports/startup/both/accounts.js');  //Ensure that the user accounts templates are setup first.  We have included the AccountTemplates routing in this document to keep all routing in one place.

//**** GROUPS
let pub = FlowRouter.group({
});
let pri = FlowRouter.group({
	//TODO: Require SSL
	triggersEnter: [AccountsTemplates.ensureSignedIn]
});

//**** ADMIN
pri.route("/admin", {
	triggersEnter: [function(context, redirect) {redirect("/Admin/Home");}]
});
pri.route("/Admin", {
	triggersEnter: [function(context, redirect) {redirect("/Admin/Home");}]
});
AccountsTemplates.configureRoute('signIn', {
	name: 'SignIn',
	path: '/Admin/SignIn'
});
AccountsTemplates.configureRoute('resetPwd', {
	name: 'ResetPwd',
	path: '/Admin/ResetPwd'
});
AccountsTemplates.configureRoute('forgotPwd', {
	name: 'ForgotPwd',
	path: '/Admin/ForgotPwd'
});

pri.route("/Admin/Home", {
	name: "AdminHome",
	action: function(params, queryParams) {
		require("/imports/ui/AdminHome.js");
		BlazeLayout.render("Admin", {content: "AdminHome"})
	}
});
pri.route("/Admin/UserManagement", {
	name: "UserManagement",
	action: function(params, queryParams) {
		require("/imports/ui/UserManagement.js");
		BlazeLayout.render("Admin", {content: "UserManagement"})
	}
});

//*** PUBLIC
pub.route('/', {
	triggersEnter: [function(context, redirect) {redirect("/Home");}]
});
pub.route("/Home", {
	name: 'Home',
	action: function(params, queryParams) {
		require("/imports/ui/Home.js");
		BlazeLayout.render("Public", {content: "Home"});
	}
});
