aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/users
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/users')
-rw-r--r--shared/extra-utils/users/login.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/shared/extra-utils/users/login.ts b/shared/extra-utils/users/login.ts
index b12b51b8c..275bb0826 100644
--- a/shared/extra-utils/users/login.ts
+++ b/shared/extra-utils/users/login.ts
@@ -95,6 +95,26 @@ function setAccessTokensToServers (servers: ServerInfo[]) {
95 return Promise.all(tasks) 95 return Promise.all(tasks)
96} 96}
97 97
98function loginUsingExternalToken (server: Server, username: string, externalAuthToken: string, expectedStatus = 200) {
99 const path = '/api/v1/users/token'
100
101 const body = {
102 client_id: server.client.id,
103 client_secret: server.client.secret,
104 username: username,
105 response_type: 'code',
106 grant_type: 'password',
107 scope: 'upload',
108 externalAuthToken
109 }
110
111 return request(server.url)
112 .post(path)
113 .type('form')
114 .send(body)
115 .expect(expectedStatus)
116}
117
98// --------------------------------------------------------------------------- 118// ---------------------------------------------------------------------------
99 119
100export { 120export {
@@ -107,5 +127,6 @@ export {
107 setAccessTokensToServers, 127 setAccessTokensToServers,
108 Server, 128 Server,
109 Client, 129 Client,
110 User 130 User,
131 loginUsingExternalToken
111} 132}