private async validateAndGenerateUserCredentials()

in src/bll/commands/signin.ts [85:116]


    private async validateAndGenerateUserCredentials(serverUrl: string,
                                                     user: string,
                                                     password: string,
                                                     silent: boolean = false): Promise<Credentials> {
        if (!(serverUrl && user && password)) {
            Logger.logDebug(`SignIn#validateAndGenerateUserCredentials: credentials are undefined.`);
            return Promise.reject("Credentials are undefined.");
        }

        const promise: Promise<Credentials> = new Promise<Credentials>((resolve, reject) => {
            Logger.logDebug(`SignIn#validateAndGenerateUserCredentials: credentials are not undefined and should be validated`);
            this.remoteLogin.authenticate(serverUrl, user, password).then((unParsedColonValues: string) => {
                const loginInfo: string[] = Utils.parseValueColonValue(unParsedColonValues);
                const authenticationSuccessful = !!loginInfo;
                if (authenticationSuccessful) {
                    const sessionId = loginInfo[0];
                    const userId = loginInfo[1];
                    resolve(new Credentials(serverUrl, user, password, userId, sessionId));
                } else {
                    Logger.logDebug(`SignIn#validateAndGenerateUserCredentials: credentials were not passed an authentication check.`);
                    reject(MessageConstants.STATUS_CODE_401);
                }
            }).catch((err) => {
                reject(err);
            });
        });
        if (!silent) {
            this.windowProxy.showWithProgress("Signing in to a TeamCity server", promise);
        }

        return promise;
    }