File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ describe('api/authentication/signInWithPassword', () => {
76
76
) ;
77
77
} ) ;
78
78
79
- it ( 'should handle errors' , async ( ) => {
79
+ it ( 'should handle errors for invalid password ' , async ( ) => {
80
80
const mock = mockEndpoint (
81
81
Endpoint . SIGN_IN_WITH_PASSWORD ,
82
82
{
@@ -99,6 +99,31 @@ describe('api/authentication/signInWithPassword', () => {
99
99
) ;
100
100
expect ( mock . calls [ 0 ] . request ) . to . eql ( request ) ;
101
101
} ) ;
102
+
103
+ it ( 'should handle errors for missing password' , async ( ) => {
104
+ request . password = '' ;
105
+ const mock = mockEndpoint (
106
+ Endpoint . SIGN_IN_WITH_PASSWORD ,
107
+ {
108
+ error : {
109
+ code : 400 ,
110
+ message : ServerError . MISSING_PASSWORD ,
111
+ errors : [
112
+ {
113
+ message : ServerError . MISSING_PASSWORD
114
+ }
115
+ ]
116
+ }
117
+ } ,
118
+ 400
119
+ ) ;
120
+
121
+ await expect ( signInWithPassword ( auth , request ) ) . to . be . rejectedWith (
122
+ FirebaseError ,
123
+ 'Firebase: A non-empty password must be provided (auth/missing-password).'
124
+ ) ;
125
+ expect ( mock . calls [ 0 ] . request ) . to . eql ( request ) ;
126
+ } ) ;
102
127
} ) ;
103
128
104
129
describe ( 'api/authentication/sendEmailVerification' , ( ) => {
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ export const SERVER_ERROR_MAP: Partial<ServerErrorMap<ServerError>> = {
134
134
// Sign in with email and password errors (some apply to sign up too).
135
135
[ ServerError . INVALID_PASSWORD ] : AuthErrorCode . INVALID_PASSWORD ,
136
136
// This can only happen if the SDK sends a bad request.
137
- [ ServerError . MISSING_PASSWORD ] : AuthErrorCode . INTERNAL_ERROR ,
137
+ [ ServerError . MISSING_PASSWORD ] : AuthErrorCode . MISSING_PASSWORD ,
138
138
139
139
// Sign up with email and password errors.
140
140
[ ServerError . EMAIL_EXISTS ] : AuthErrorCode . EMAIL_EXISTS ,
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ export const enum AuthErrorCode {
89
89
MISSING_MFA_INFO = 'missing-multi-factor-info' ,
90
90
MISSING_MFA_SESSION = 'missing-multi-factor-session' ,
91
91
MISSING_PHONE_NUMBER = 'missing-phone-number' ,
92
+ MISSING_PASSWORD = 'missing-password' ,
92
93
MISSING_SESSION_INFO = 'missing-verification-id' ,
93
94
MODULE_DESTROYED = 'app-deleted' ,
94
95
NEED_CONFIRMATION = 'account-exists-with-different-credential' ,
@@ -267,6 +268,7 @@ function _debugErrorMap(): ErrorMap<AuthErrorCode> {
267
268
'The request does not contain a valid nonce. This can occur if the ' +
268
269
'SHA-256 hash of the provided raw nonce does not match the hashed nonce ' +
269
270
'in the ID token payload.' ,
271
+ [ AuthErrorCode . MISSING_PASSWORD ] : 'A non-empty password must be provided' ,
270
272
[ AuthErrorCode . MISSING_MFA_INFO ] :
271
273
'No second factor identifier is provided.' ,
272
274
[ AuthErrorCode . MISSING_MFA_SESSION ] :
You can’t perform that action at this time.
0 commit comments