Skip to content

Commit f478934

Browse files
committed
Merge pull request #1015 from steida/patch-1
Make requireAuth more ES6ish.
2 parents 20b8719 + e07f53c commit f478934

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

examples/auth-flow/app.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,16 @@ class App extends React.Component {
4141
}
4242

4343
var requireAuth = (Component) => {
44-
class Authenticated extends React.Component {
44+
return class Authenticated extends React.Component {
45+
static willTransitionTo(transition) {
46+
if (!auth.loggedIn()) {
47+
transition.redirect('/login', {}, {'nextPath' : transition.path});
48+
}
49+
}
4550
render () {
4651
return <Component {...this.props}/>
4752
}
4853
}
49-
50-
Authenticated.willTransitionTo = function (transition) {
51-
var nextPath = transition.path;
52-
if (!auth.loggedIn()) {
53-
transition.redirect('/login',{},
54-
{ 'nextPath' : nextPath });
55-
}
56-
};
57-
58-
return Authenticated;
5954
};
6055

6156
var Dashboard = requireAuth(class extends React.Component {

0 commit comments

Comments
 (0)