Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Labels
Plan
Issues
25
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cokoapps
server
Commits
f17e633e
Commit
f17e633e
authored
2 years ago
by
Yannis Barlas
Browse files
Options
Downloads
Patches
Plain Diff
fix(models): get base model for service credentials from local file
parent
5b06158a
No related branches found
No related tags found
2 merge requests
!52
Docx
,
!17
Graphql api
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/models/serviceCredential/serviceCredential.model.js
+1
-1
1 addition, 1 deletion
src/models/serviceCredential/serviceCredential.model.js
src/utils/getAccessToken.js
+7
-10
7 additions, 10 deletions
src/utils/getAccessToken.js
with
8 additions
and
11 deletions
src/models/serviceCredential/serviceCredential.model.js
+
1
−
1
View file @
f17e633e
const
BaseModel
=
require
(
'
@pubsweet
/base
-
model
'
)
const
BaseModel
=
require
(
'
..
/base
.
model
'
)
const
{
string
,
stringNotEmpty
}
=
require
(
'
../_helpers/types
'
)
...
...
This diff is collapsed.
Click to expand it.
src/utils/getAccessToken.js
+
7
−
10
View file @
f17e633e
...
...
@@ -36,7 +36,7 @@ const getAccessToken = async (serviceName, renew = false) => {
throw
new
Error
(
`service
${
serviceName
}
is down`
)
}
const
foundServiceCredential
=
await
ServiceCredential
.
query
().
findOne
({
const
foundServiceCredential
=
await
ServiceCredential
.
findOne
({
name
:
serviceName
,
})
...
...
@@ -48,7 +48,7 @@ const getAccessToken = async (serviceName, renew = false) => {
})
const
{
accessToken
}
=
data
await
ServiceCredential
.
query
().
insert
({
await
ServiceCredential
.
insert
({
name
:
serviceName
,
accessToken
,
})
...
...
@@ -65,7 +65,7 @@ const getAccessToken = async (serviceName, renew = false) => {
})
const
{
accessToken
:
freshAccessToken
}
=
data
await
ServiceCredential
.
query
().
patchAndFetchById
(
id
,
{
await
ServiceCredential
.
patchAndFetchById
(
id
,
{
accessToken
:
freshAccessToken
,
})
return
freshAccessToken
...
...
@@ -73,17 +73,14 @@ const getAccessToken = async (serviceName, renew = false) => {
return
accessToken
}
catch
(
e
)
{
const
foundServiceCredential
=
await
ServiceCredential
.
query
().
findOne
({
const
foundServiceCredential
=
await
ServiceCredential
.
findOne
({
name
:
serviceName
,
})
if
(
foundServiceCredential
)
{
await
ServiceCredential
.
query
().
patchAndFetchById
(
foundServiceCredential
.
id
,
{
accessToken
:
null
,
},
)
await
ServiceCredential
.
patchAndFetchById
(
foundServiceCredential
.
id
,
{
accessToken
:
null
,
})
}
throw
new
Error
(
e
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment