You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+70-48
Original file line number
Diff line number
Diff line change
@@ -58,81 +58,78 @@ AccountsTemplates.configure({
58
58
});
59
59
```
60
60
61
-
Useraccounts:flow-routing uses the internal useraccounts
62
-
63
-
```fullPageAtForm``` is the built-in template useraccounts uses by default for its forms. You can override it on a per-route basis (see below) or replace it with ```defaultTemplate:``` field as above (templates specified in route config will still take precedence). Omit ```defaultTemplate``` (or set to an empty string) to use the ```fullPageAtForm``` template built-in to your useraccounts UI package (ex [material](https://github.com/meteor-useraccounts/materialize/blob/master/lib/full_page_at_form.html)).
61
+
`useraccounts:flow-routing` uses the internal useraccounts `fullPageAtForm` is the built-in template useraccounts uses by default for its forms. You can override it on a per-route basis (see below) or replace it with `defaultTemplate:` field as above (templates specified in route config will still take precedence). Omit `defaultTemplate` (or set to an empty string) to use the `fullPageAtForm` template built-in to your useraccounts UI package (ex [material](https://github.com/meteor-useraccounts/materialize/blob/master/lib/full_page_at_form.html)).
64
62
65
63
NOTE: The above configs must load BEFORE your AccountsTemplates routes are defined (next section).
66
64
67
65
## React Configuration
68
66
69
-
Firstly, please ensure that your app depends upon the [React Layout][3] and the [Blaze Layout][2] packages.
70
-
User Accounts currents only renders Blaze templates. In order to use User Accounts with React we rely on the [Blaze To React][4] package to render the User Accounts templates.
67
+
Firstly, please ensure that your app depends upon the [React Layout][3] and the [Blaze Layout][2] packages. User Accounts currents only renders Blaze templates. In order to use User Accounts with React we rely on the [Blaze To React][4] package to render the User Accounts templates.
71
68
72
69
Before you configure routes for User Accounts with Flow Router, you will need to make sure you have set a few default configuration items.
73
70
74
-
Assuming you have a main layout that looks like this:
71
+
Assuming you have a main layout that looks like following and you have `<Nav />` and `<Footer />` as your default nav/footer components:
75
72
76
73
```jsx
77
74
MainLayout =React.createClass({
78
75
render() {
79
-
return<div>
80
-
<header>
81
-
{this.props.header}
82
-
</header>
83
-
<main>
84
-
{this.props.main}
85
-
</main>
86
-
<footer>
87
-
{this.props.footer}
88
-
</footer>
89
-
</div>
76
+
return (
77
+
<div>
78
+
<header>
79
+
{this.props.nav||<Nav />}
80
+
</header>
81
+
<main>
82
+
{this.props.main}
83
+
</main>
84
+
<footer>
85
+
{this.props.footer||<Footer />}
86
+
</footer>
87
+
</div>
88
+
);
90
89
}
91
90
});
92
91
```
93
92
94
-
You would configure this package to use it like this:
93
+
You would then configure this package to use it like this:
95
94
96
95
```js
97
96
AccountsTemplates.configure({
98
-
defaultLayoutType:'blaze-to-react',
99
-
defaultTemplate:'myCustomFullPageAtForm',
100
-
defaultLayout: MainLayout,
101
-
defaultLayoutRegions: {
102
-
header:<MyNav/>,
103
-
footer:<MyFooter/>
104
-
},
105
-
defaultContentRegion:'main'
97
+
defaultLayoutType:'blaze-to-react',
98
+
defaultTemplate:'fullPageAtForm', // default
99
+
defaultLayout: MainLayout,
100
+
defaultLayoutRegions: {
101
+
nav:<Nav/>,
102
+
footer:<Footer/>
103
+
},
104
+
defaultContentRegion:'main'
106
105
});
107
106
```
108
107
109
-
If you don't have extra content regions (nav, footer, etc) you should pass an empty object to ```defaultLayoutRegions``` key of the config.
108
+
If you don't have extra content regions (nav, footer, etc) you should pass an empty object to the `defaultLayoutRegions` key of the config.
110
109
111
110
```js
112
111
AccountsTemplates.configure({
113
112
defaultLayoutType:'blaze-to-react',
114
-
defaultTemplate:'myCustomFullPageAtForm',
115
-
defaultLayout: MainLayout,
116
-
defaultLayoutRegions: {},
117
-
defaultContentRegion:'main'
113
+
defaultTemplate:'myCustomFullPageAtForm',
114
+
defaultLayout: MainLayout,
115
+
defaultLayoutRegions: {},
116
+
defaultContentRegion:'main'
118
117
});
119
118
```
120
-
Useraccounts:flow-routing uses the internal useraccounts
121
119
122
-
```fullPageAtForm```is the built-in **Blaze** template useraccounts uses by default for its forms. You can override it on a per-route basis (see below) or replace it with ```defaultTemplate:``` field as above (templates specified in route config will still take precedence). Omit ```defaultTemplate``` (or set to an empty string) to use the ```fullPageAtForm``` template built-in to your useraccounts UI package (ex [material](https://github.com/meteor-useraccounts/materialize/blob/master/lib/full_page_at_form.html)).
120
+
`useraccounts:flow-routing` uses `fullPageAtForm` for the `defaultTemplate` option. `fullPageAtForm`is the built-in Blaze template that all UserAccounts themed packages (Bootstrap, Materialize, etc.) use for their forms. You can override it on a per-route basis (see below) or replace it as shown above (templates specified in a route config will still take precedence). Omit `defaultTemplate` (or set to an empty string) to use the `fullPageAtForm` template built-in to your useraccounts UI package (ex [material](https://github.com/meteor-useraccounts/materialize/blob/master/lib/full_page_at_form.html)).
123
121
124
122
Please note that this template must be a **Blaze** template. It will be rendered into your React layout using [Blaze To React][4].
125
123
126
124
NOTE: The above configs must load BEFORE your AccountsTemplates routes are defined (next section).
127
125
128
-
129
126
## Routes
130
127
131
128
There are no routes provided by default, but you can easily configure routes for sign in, sign up, forgot password, reset password, change password, enroll account using `AccountsTemplates.configureRoute`.
132
129
133
130
The simplest way is to make the call passing in only a route code (available route codes are: signIn, signUp, changePwd, forgotPwd, resetPwd, enrollAccount).
134
131
135
-
This will set up the sign in route with a full-page form:
132
+
This will set up the sign in route with a full-page form at `/sign-in`:
The following is a complete example of a custom route configuration:
148
145
146
+
##### Blaze
147
+
149
148
```js
149
+
// routes.js
150
+
150
151
AccountsTemplates.configureRoute('signIn', {
151
-
layoutType:'blaze',
152
-
name:'signin',
153
-
path:'/login',
154
-
template:'myLogin',
155
-
layoutTemplate:'myLayout',
156
-
layoutRegions: {
157
-
nav:'myNav',
158
-
footer:'myFooter'
159
-
},
160
-
contentRegion:'main'
152
+
layoutType:'blaze',
153
+
name:'signin',
154
+
path:'/login',
155
+
template:'myLogin',
156
+
layoutTemplate:'myLayout',
157
+
layoutRegions: {
158
+
nav:'customNav',
159
+
footer:'customFooter'
160
+
},
161
+
contentRegion:'main'
162
+
});
163
+
```
164
+
165
+
##### React
166
+
167
+
```jsx
168
+
// routes.jsx
169
+
170
+
AccountsTemplates.configureRoute('signIn', {
171
+
layoutType:'blaze-to-react',
172
+
name:'signin',
173
+
path:'/login',
174
+
template:'myLogin',
175
+
layoutTemplate: CustomLayout,
176
+
layoutRegions: {
177
+
nav:<CustomNav />,
178
+
footer:<CustomFooter />
179
+
},
180
+
contentRegion:'main'
161
181
});
162
182
```
163
183
164
184
All options are passed to FlowRouter.route() which then creates a new custom route (see the official Flow Router documentation [here](https://atmospherejs.com/kadira/flow-router) for more details).
165
185
166
-
All the above fields are optional and fall back to default values in case you don't provide them. Default values are as follows:
186
+
Default values for all fields are as follows:
167
187
168
188
| Action | route_code | Route Name | Route Path | Template | Redirect after Timeout |
0 commit comments