File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 1+ - Fixes bug where ` toJSON ` was not defined in ` UserRecord ` (#1125 ).
Original file line number Diff line number Diff line change @@ -88,6 +88,34 @@ describe('identity', () => {
8888 lastSignInTime : '2017-02-02T23:01:19.797Z' ,
8989 } ) ;
9090 } ) ;
91+
92+ it ( 'should stringify the record' , ( ) => {
93+ const raw : any = {
94+ uid : '123' ,
95+ email : 'email@gmail.com' ,
96+ emailVerified : true ,
97+ displayName : 'User' ,
98+ photoURL : 'url' ,
99+ phoneNumber : '1233332222' ,
100+ disabled : true ,
101+ providerData : [ 'something' ] ,
102+ customClaims : {
103+ claim : 'value' ,
104+ another : {
105+ inner : 'value' ,
106+ } ,
107+ } ,
108+ passwordSalt : 'abc' ,
109+ passwordHash : 'def' ,
110+ tokensValidAfterTime : '2027-02-02T23:01:19.797Z' ,
111+ metadata : {
112+ creationTime : '2017-02-02T23:06:26.124Z' ,
113+ lastSignInTime : '2017-02-02T23:01:19.797Z' ,
114+ } ,
115+ } ;
116+ const record = identity . userRecordConstructor ( raw ) ;
117+ expect ( ( ) => JSON . stringify ( record ) ) . to . not . throw ;
118+ } ) ;
91119 } ) ;
92120
93121 describe ( 'isValidRequest' , ( ) => {
Original file line number Diff line number Diff line change @@ -146,7 +146,11 @@ export function userRecordConstructor(wireData: Object): UserRecord {
146146 } ;
147147 json . metadata = record . metadata . toJSON ( ) ;
148148 json . customClaims = JSON . parse ( JSON . stringify ( record . customClaims ) ) ;
149- json . providerData = record . providerData . map ( ( entry ) => entry . toJSON ( ) ) ;
149+ json . providerData = record . providerData . map ( ( entry ) => {
150+ const newEntry = { ...entry } ;
151+ newEntry . toJSON = ( ) => entry ;
152+ return newEntry ;
153+ } ) ;
150154 return json ;
151155 } ;
152156 return record as UserRecord ;
You can’t perform that action at this time.
0 commit comments