mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: implement 'login' event for net.ClientRequest (#21135)
* fix: implement 'login' event for net.ClientRequest (#21096) * fix patch * lint * include mojo header in atom_browser_context.h * fix compile * kick ci * URLRequest -> URLRequestNS * fix ts * no ts in js
This commit is contained in:
committed by
John Kleinschmidt
parent
fbe36e2365
commit
de428e9a7a
@@ -247,22 +247,11 @@ class ClientRequest extends EventEmitter {
|
||||
})
|
||||
|
||||
urlRequest.on('login', (event, authInfo, callback) => {
|
||||
this.emit('login', authInfo, (username, password) => {
|
||||
// If null or undefined username/password, force to empty string.
|
||||
if (username === null || username === undefined) {
|
||||
username = ''
|
||||
}
|
||||
if (typeof username !== 'string') {
|
||||
throw new Error('username must be a string')
|
||||
}
|
||||
if (password === null || password === undefined) {
|
||||
password = ''
|
||||
}
|
||||
if (typeof password !== 'string') {
|
||||
throw new Error('password must be a string')
|
||||
}
|
||||
callback(username, password)
|
||||
})
|
||||
const handled = this.emit('login', authInfo, callback)
|
||||
if (!handled) {
|
||||
// If there were no listeners, cancel the authentication request.
|
||||
callback()
|
||||
}
|
||||
})
|
||||
|
||||
if (callback) {
|
||||
|
||||
Reference in New Issue
Block a user