File tree Expand file tree Collapse file tree 4 files changed +32
-18
lines changed Expand file tree Collapse file tree 4 files changed +32
-18
lines changed Original file line number Diff line number Diff line change @@ -67,15 +67,17 @@ module.exports = function(app){
67
67
}
68
68
69
69
var displayName = "" ;
70
-
70
+ var email = "" ;
71
+ var loggedIn = false ;
71
72
if ( req . user ) {
72
- if ( req . user . twitter ) {
73
- displayName = req . user . twitter . displayName ;
74
- }
73
+ displayName = req . user . displayName ( ) ;
74
+ loggedIn = true ;
75
75
}
76
76
77
77
res . render ( 'index.ejs' , {
78
- user : displayName ,
78
+ displayName : displayName ,
79
+ email : email ,
80
+ loggedIn : loggedIn ,
79
81
content : content ,
80
82
scriptPath : scriptPath ,
81
83
cssPath : cssPath ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ var userSchema = mongoose.Schema({
7
7
8
8
email : String ,
9
9
password : String ,
10
+ name : String ,
10
11
11
12
facebook : {
12
13
id : String ,
@@ -39,5 +40,14 @@ userSchema.methods.validPassword = function(password) {
39
40
return bcrypt . compareSync ( password , this . password ) ;
40
41
} ;
41
42
43
+ userSchema . methods . displayName = function ( ) {
44
+ return this . name || this . facebook . name || this . twitter . displayName ;
45
+ } ;
46
+
47
+ userSchema . methods . username = function ( ) {
48
+ return this . twitter . username ;
49
+ } ;
50
+
51
+
42
52
// create the model for users and expose it to our app
43
53
module . exports = mongoose . model ( 'User' , userSchema ) ;
Original file line number Diff line number Diff line change 11
11
<script type =" text/javascript" >
12
12
var GlobalSettings = {
13
13
apiUrl: " <%= apiPath %>" ,
14
- user: " <%= user %>"
14
+ displayName: " <%= displayName %>" ,
15
+ email: " <%= email %>" ,
16
+ loggedIn: < %= loggedIn % >
15
17
}
16
18
</script >
17
19
</head >
Original file line number Diff line number Diff line change @@ -5,45 +5,45 @@ import Constants from "../constants";
5
5
import StoreCommon from "./store_common" ;
6
6
import assign from "object-assign" ;
7
7
8
- let _user = { } ;
8
+ var _user = { } ;
9
9
10
10
// log the user in
11
- function login ( email , password ) {
12
- return true ;
11
+ function login ( email , displayName , password ) {
12
+ _user . email = email ;
13
+ _user . loggedIn = true ;
14
+ _user . displayName = displayName ;
13
15
}
14
16
15
17
// Register
16
18
function register ( user ) {
17
- return true ;
19
+ _user . email = user . email ;
20
+ _user . loggedIn = true ;
21
+ _user . displayName = user . displayName ;
18
22
}
19
23
20
24
// Extend User Store with EventEmitter to add eventing capabilities
21
- let UserStore = assign ( { } , StoreCommon , {
25
+ var UserStore = assign ( { } , StoreCommon , {
22
26
23
27
// Return current user
24
28
current ( ) {
25
29
return _user ;
26
30
} ,
27
31
28
32
loggedIn ( ) {
29
- return _user . email !== undefined ;
30
- } ,
31
-
32
- token ( ) {
33
- return _user . token ;
33
+ return _user . loggedIn ;
34
34
}
35
35
36
36
} ) ;
37
37
38
38
// Register callback with Dispatcher
39
39
Dispatcher . register ( function ( payload ) {
40
- let action = payload . action ;
40
+ var action = payload . action ;
41
41
42
42
switch ( action ) {
43
43
44
44
// Respond to LOGIN action
45
45
case Constants . LOGIN :
46
- login ( payload . email , payload . password ) ;
46
+ login ( payload . email , payload . displayName , payload . password ) ;
47
47
break ;
48
48
49
49
// Respond to REGISTER action
You can’t perform that action at this time.
0 commit comments