import { AccountsTemplates } from 'meteor/useraccounts:core';

AccountsTemplates.configure({
	forbidClientAccountCreation: true,  //Turn off client side account creation.  The app is expected to have a feature that will do this.
	showForgotPasswordLink: true,
	defaultTemplate: 'OverrideAtForm',
	//defaultTemplate: 'AuthorizationPage',  //The template for all the forms related to logging in or out.
	defaultLayout: 'Login',  //What page template to place the defaultTemplate in.
	defaultContentRegion: 'content',  //The content region of the page template to place the defaultTemplate in.
	defaultLayoutRegions: {},
	// defaultLayout: 'Body',
	// defaultContentRegion: 'content',
	// defaultLayoutRegions: {}
	texts: {
		title: {
			signIn: ""
		},
		button: {
			signIn: "Enter"
		}
	}
});

// This removes the password field but returns it,
// so that you can re-add it later, preserving the
// desired order of the fields
// let pwd = AccountsTemplates.removeField('password');
// AccountsTemplates.removeField('email');
// AccountsTemplates.addFields([
// 	{
// 		_id: "username",
// 		type: "text",
// 		displayName: "username",
// 		required: true,
// 		minLength: 5,
// 	},
// 	pwd
// ]);
let pwd = AccountsTemplates.removeField('password');

AccountsTemplates.removeField('email');
AccountsTemplates.addFields([
	{
		_id: "username",
		type: "text",
		displayName: "username",
		required: true,
		minLength: 5,
	},
	{
		_id: 'email',
		type: 'email',
		required: true,
		displayName: "email",
		re: /.+@(.+){2,}\.(.+){2,}/,
		errStr: 'Invalid email',
	},
	{
		_id: 'username_and_email',
		type: 'text',
		required: true,
		displayName: "Login",
		placeholder: "Login / Email"
	},
	pwd
]);

//AccountsTemplates.configureRoute('signIn', {
//	name: 'signin',
//	path: '/Admin/SignIn'
//});
//// AccountsTemplates.configureRoute('signUp', {
//// 	name: 'join',
//// 	path: '/join'
//// });
//AccountsTemplates.configureRoute('forgotPwd', {
//	name: 'forgotPwd',
//	path: '/Admin/ForgotPwd'
//});
//AccountsTemplates.configureRoute('resetPwd', {
//	name: 'resetPwd',
//	path: '/Admin/ResetPwd'
//});
