X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fextra-utils%2Fusers%2Flogin-command.ts;h=b4e3bb602cb2f9151e453dcc69c8ca278fb07720;hb=7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0;hp=97efcb766618b375c02c3d3f0cb5389684528e94;hpb=41d1d075011174e73dccb74006181a92a618d7b4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/extra-utils/users/login-command.ts b/shared/extra-utils/users/login-command.ts index 97efcb766..b4e3bb602 100644 --- a/shared/extra-utils/users/login-command.ts +++ b/shared/extra-utils/users/login-command.ts @@ -1,4 +1,3 @@ -import { PeerTubeRequestError } from '@server/helpers/requests' import { HttpStatusCode } from '@shared/core-utils' import { PeerTubeProblemDocument } from '@shared/models' import { unwrapBody } from '../requests' @@ -8,7 +7,7 @@ export class LoginCommand extends AbstractCommand { login (options: OverrideCommandOptions & { client?: { id?: string, secret?: string } - user?: { username: string, password: string } + user?: { username: string, password?: string } } = {}) { const { client = this.server.client, user = this.server.user } = options const path = '/api/v1/users/token' @@ -17,7 +16,7 @@ export class LoginCommand extends AbstractCommand { client_id: client.id, client_secret: client.secret, username: user.username, - password: user.password, + password: user.password ?? 'password', response_type: 'code', grant_type: 'password', scope: 'upload' @@ -34,10 +33,10 @@ export class LoginCommand extends AbstractCommand { })) } - getAccessToken (user?: { username: string, password: string }): Promise - getAccessToken (username: string, password: string): Promise - async getAccessToken (arg1?: { username: string, password: string } | string, password?: string) { - let user: { username: string, password: string } + getAccessToken (arg1?: { username: string, password?: string }): Promise + getAccessToken (arg1: string, password?: string): Promise + async getAccessToken (arg1?: { username: string, password?: string } | string, password?: string) { + let user: { username: string, password?: string } if (!arg1) user = this.server.user else if (typeof arg1 === 'object') user = arg1 @@ -48,7 +47,7 @@ export class LoginCommand extends AbstractCommand { return body.access_token } catch (err) { - throw new Error('Cannot authenticate. Please check your username/password.') + throw new Error(`Cannot authenticate. Please check your username/password. (${err})`) } }