Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
backbone-adapter-javascript
Commits
71be5f45
Verified
Commit
71be5f45
authored
1 month ago
by
Dan Jones
Browse files
Options
Download
Email Patches
Plain Diff
fix: wait for authentication for fast polling rates
parent
f4ff9deb
dev
master
v1.0.0
2 merge requests
!21
Release v1.0.0
,
!20
Resolve "Fix fast polling race condition"
Pipeline
#262741
passed with stages
in 1 minute and 37 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
0 deletions
+31
-0
CHANGELOG.md
CHANGELOG.md
+4
-0
dist/adapter.esm.js
dist/adapter.esm.js
+9
-0
dist/adapter.js
dist/adapter.js
+9
-0
src/adapter/index.js
src/adapter/index.js
+9
-0
No files found.
CHANGELOG.md
View file @
71be5f45
...
...
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Fixed
-
Wait for authentication to complete for fast polling rates
### Changed
-
Add hyphen to regex for schema version to enable issue branches
...
...
This diff is collapsed.
Click to expand it.
dist/adapter.esm.js
View file @
71be5f45
...
...
@@ -8,6 +8,7 @@ class Adapter {
this
.
protocol
=
protocol
;
this
.
config
=
config
;
this
.
axios
=
axios
;
this
.
authenticating
=
false
;
}
/**
...
...
@@ -44,6 +45,10 @@ class Adapter {
* @returns {object}
*/
getAuthorizationHeader
()
{
if
(
this
.
authenticating
)
{
// return an pseudo response with an ignored status
return
Promise
.
reject
({
response
:
{
status
:
405
}
});
}
if
(
!
this
.
tokenValid
())
return
this
.
auth
().
then
((
response
)
=>
{
return
{
...
...
@@ -62,6 +67,7 @@ class Adapter {
* @returns {object}
*/
auth
()
{
this
.
authenticating
=
true
;
let
adapterConfig
=
this
.
config
;
return
this
.
axios
.
get
(
`
${
adapterConfig
.
api
}
/token`
,
{
...
...
@@ -72,9 +78,11 @@ class Adapter {
})
.
then
((
response
)
=>
{
this
.
credentials
=
response
.
data
;
this
.
authenticating
=
false
;
return
response
;
})
.
catch
((
error
)
=>
{
this
.
authenticating
=
false
;
return
Promise
.
reject
(
error
);
});
}
...
...
@@ -116,6 +124,7 @@ class Adapter {
retry
=
true
;
}
break
;
// ignore 405 from auth in progress
case
503
:
{
retry
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
dist/adapter.js
View file @
71be5f45
...
...
@@ -10,6 +10,7 @@ class Adapter {
this
.
protocol
=
protocol
;
this
.
config
=
config
;
this
.
axios
=
axios
;
this
.
authenticating
=
false
;
}
/**
...
...
@@ -46,6 +47,10 @@ class Adapter {
* @returns {object}
*/
getAuthorizationHeader
()
{
if
(
this
.
authenticating
)
{
// return an pseudo response with an ignored status
return
Promise
.
reject
({
response
:
{
status
:
405
}
});
}
if
(
!
this
.
tokenValid
())
return
this
.
auth
().
then
((
response
)
=>
{
return
{
...
...
@@ -64,6 +69,7 @@ class Adapter {
* @returns {object}
*/
auth
()
{
this
.
authenticating
=
true
;
let
adapterConfig
=
this
.
config
;
return
this
.
axios
.
get
(
`
${
adapterConfig
.
api
}
/token`
,
{
...
...
@@ -74,9 +80,11 @@ class Adapter {
})
.
then
((
response
)
=>
{
this
.
credentials
=
response
.
data
;
this
.
authenticating
=
false
;
return
response
;
})
.
catch
((
error
)
=>
{
this
.
authenticating
=
false
;
return
Promise
.
reject
(
error
);
});
}
...
...
@@ -118,6 +126,7 @@ class Adapter {
retry
=
true
;
}
break
;
// ignore 405 from auth in progress
case
503
:
{
retry
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
src/adapter/index.js
View file @
71be5f45
...
...
@@ -8,6 +8,7 @@ export class Adapter {
this
.
protocol
=
protocol
;
this
.
config
=
config
;
this
.
axios
=
axios
;
this
.
authenticating
=
false
;
}
/**
...
...
@@ -44,6 +45,10 @@ export class Adapter {
* @returns {object}
*/
getAuthorizationHeader
()
{
if
(
this
.
authenticating
)
{
// return an pseudo response with an ignored status
return
Promise
.
reject
({
response
:
{
status
:
405
}
});
}
if
(
!
this
.
tokenValid
())
return
this
.
auth
().
then
((
response
)
=>
{
return
{
...
...
@@ -62,6 +67,7 @@ export class Adapter {
* @returns {object}
*/
auth
()
{
this
.
authenticating
=
true
;
let
adapterConfig
=
this
.
config
;
return
this
.
axios
.
get
(
`
${
adapterConfig
.
api
}
/token`
,
{
...
...
@@ -72,9 +78,11 @@ export class Adapter {
})
.
then
((
response
)
=>
{
this
.
credentials
=
response
.
data
;
this
.
authenticating
=
false
;
return
response
;
})
.
catch
((
error
)
=>
{
this
.
authenticating
=
false
;
return
Promise
.
reject
(
error
);
});
}
...
...
@@ -116,6 +124,7 @@ export class Adapter {
retry
=
true
;
}
break
;
// ignore 405 from auth in progress
case
503
:
{
retry
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment