File tree 3 files changed +12
-7
lines changed
3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -234,14 +234,14 @@ export const resolvers = {
234
234
return context . NewsItem . hideNewsItem ( id , context . userId ) ;
235
235
} ,
236
236
237
- submitNewsItem : ( _ , args , context ) => {
237
+ submitNewsItem : ( _ , newsItem , context ) => {
238
238
if ( ! context . userId ) throw new Error ( 'Must be logged in to submit a news item.' ) ;
239
- return context . NewsItem . submitNewsItem ( { ...args , submitterId : context . userId } ) ;
239
+ return context . NewsItem . submitNewsItem ( { ...newsItem , submitterId : context . userId } ) ;
240
240
} ,
241
241
242
- registerUser : ( _ , args , context ) => {
242
+ registerUser : ( _ , user , context ) => {
243
243
if ( context . userId ) throw new Error ( 'Logged in user cannot register a user' ) ;
244
- return context . User . registerUser ( args ) ;
244
+ return context . User . registerUser ( user ) ;
245
245
} ,
246
246
} ,
247
247
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ const Page = ({ registerUser, url }) => {
88
88
</ tbody >
89
89
</ table >
90
90
< br />
91
- < input type = "submit" value = "create account" onClick = { ( ) => registerUser ( user , pass ) } />
91
+ < input type = "submit" value = "create account" /* onClick={() => registerUser(user, pass)} */ />
92
92
</ form >
93
93
</ Blank >
94
94
) ;
Original file line number Diff line number Diff line change @@ -84,8 +84,13 @@ app.prepare()
84
84
server . use ( passport . session ( ) ) ;
85
85
86
86
server . post ( '/login' , ( req , res , next ) => {
87
- if ( req . body . creating ) req . session . returnTo = `${ req . body . goto } ${ req . body . username } ` ;
88
- else req . session . returnTo = req . body . goto ;
87
+ if ( req . body . creating && ! req . user ) {
88
+ User . registerUser ( {
89
+ id : req . body . username ,
90
+ password : req . body . password ,
91
+ } ) ;
92
+ req . session . returnTo = `${ req . body . goto } ${ req . body . username } ` ;
93
+ } else req . session . returnTo = req . body . goto ;
89
94
next ( ) ;
90
95
} , passport . authenticate (
91
96
'local' ,
You can’t perform that action at this time.
0 commit comments