Show error on login screen if rune is incorrect and getinfo throws error

pull/1391/head
ShahanaFarooqui 3 weeks ago
parent a96422f9c4
commit 93c841e98c

@ -303,15 +303,7 @@ export class CommonService {
}
};
this.handleError = (errRes, fileName, errMsg, selectedNode) => {
let err = JSON.parse(JSON.stringify(errRes));
if (err && err.error && Object.keys(err.error).length === 0 && errRes.error && (errRes.error.stack || errRes.error.message)) {
errRes.error = errRes.error.stack || errRes.error.message;
err = JSON.parse(JSON.stringify(errRes));
}
else if (errRes.message || errRes.stack) {
errRes.error = errRes.message || errRes.stack;
err = JSON.parse(JSON.stringify(errRes));
}
const err = JSON.parse(JSON.stringify(errRes));
if (!selectedNode) {
selectedNode = this.selectedNode;
}
@ -325,11 +317,11 @@ export class CommonService {
}
break;
case 'CLN':
if (err.options && err.options.headers && err.options.headers.macaroon) {
delete err.options.headers.macaroon;
if (err.options && err.options.headers && err.options.headers.rune) {
delete err.options.headers.rune;
}
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.rune) {
delete err.response.request.headers.rune;
}
break;
case 'ECL':

@ -375,9 +375,9 @@ export class ConfigService {
fs.writeFileSync(confFileFullPath, JSON.stringify(config, null, 2), 'utf-8');
};
this.setServerConfiguration = () => {
const rtlConfFilePath = (process?.env?.RTL_CONFIG_PATH) ? process?.env?.RTL_CONFIG_PATH : join(this.directoryName, '../..');
const confFileFullPath = rtlConfFilePath + sep + 'RTL-Config.json';
try {
const rtlConfFilePath = (process?.env?.RTL_CONFIG_PATH) ? process?.env?.RTL_CONFIG_PATH : join(this.directoryName, '../..');
const confFileFullPath = rtlConfFilePath + sep + 'RTL-Config.json';
if (!fs.existsSync(confFileFullPath)) {
fs.writeFileSync(confFileFullPath, JSON.stringify(this.setDefaultConfig(), null, 2), 'utf-8');
}
@ -390,6 +390,7 @@ export class ConfigService {
this.common.appConfig = config;
}
catch (err) {
this.logger.log({ selectedNode: this.common.selectedNode, level: 'ERROR', fileName: 'Config', msg: 'Config file path: ' + confFileFullPath });
this.logger.log({ selectedNode: this.common.selectedNode, level: 'ERROR', fileName: 'Config', msg: 'Something went wrong while configuring the node server: \n' + err });
throw new Error(err);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -323,14 +323,7 @@ export class CommonService {
};
public handleError = (errRes, fileName, errMsg, selectedNode: SelectedNode) => {
let err = JSON.parse(JSON.stringify(errRes));
if (err && err.error && Object.keys(err.error).length === 0 && errRes.error && (errRes.error.stack || errRes.error.message)) {
errRes.error = errRes.error.stack || errRes.error.message;
err = JSON.parse(JSON.stringify(errRes));
} else if (errRes.message || errRes.stack) {
errRes.error = errRes.message || errRes.stack;
err = JSON.parse(JSON.stringify(errRes));
}
const err = JSON.parse(JSON.stringify(errRes));
if (!selectedNode) { selectedNode = this.selectedNode; }
switch (selectedNode.lnImplementation) {
case 'LND':
@ -343,11 +336,11 @@ export class CommonService {
break;
case 'CLN':
if (err.options && err.options.headers && err.options.headers.macaroon) {
delete err.options.headers.macaroon;
if (err.options && err.options.headers && err.options.headers.rune) {
delete err.options.headers.rune;
}
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.rune) {
delete err.response.request.headers.rune;
}
break;

@ -353,9 +353,9 @@ export class ConfigService {
};
public setServerConfiguration = () => {
const rtlConfFilePath = (process?.env?.RTL_CONFIG_PATH) ? process?.env?.RTL_CONFIG_PATH : join(this.directoryName, '../..');
const confFileFullPath = rtlConfFilePath + sep + 'RTL-Config.json';
try {
const rtlConfFilePath = (process?.env?.RTL_CONFIG_PATH) ? process?.env?.RTL_CONFIG_PATH : join(this.directoryName, '../..');
const confFileFullPath = rtlConfFilePath + sep + 'RTL-Config.json';
if (!fs.existsSync(confFileFullPath)) {
fs.writeFileSync(confFileFullPath, JSON.stringify(this.setDefaultConfig(), null, 2), 'utf-8');
}
@ -367,6 +367,7 @@ export class ConfigService {
this.setSelectedNode(config);
this.common.appConfig = config;
} catch (err: any) {
this.logger.log({ selectedNode: this.common.selectedNode, level: 'ERROR', fileName: 'Config', msg: 'Config file path: ' + confFileFullPath });
this.logger.log({ selectedNode: this.common.selectedNode, level: 'ERROR', fileName: 'Config', msg: 'Something went wrong while configuring the node server: \n' + err });
throw new Error(err);
}

@ -109,7 +109,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.store.dispatch(login({ payload: { password: sha256(this.accessKey).toString(), defaultPassword: false } }));
}
} else {
this.router.navigate(['./login']);
this.router.navigate(['./login'], { state: { logoutReason: 'Access key too short. It should be at least 32 characters long.' } });
}
}
}
@ -145,7 +145,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
}
}
}));
this.store.dispatch(logout());
this.store.dispatch(logout({ payload: 'Logging Out. Time limit exceeded for session inactivity.' }));
}
});
if (this.sessionService.getItem('defaultPassword') === 'true') {

@ -99,7 +99,8 @@ export class CLNEffects implements OnDestroy {
}));
}, 500);
return {
type: RTLActions.LOGOUT
type: RTLActions.LOGOUT,
payload: 'Sorry Not Sorry, RTL is Bitcoin Only!'
};
} else {
this.initializeRemainingData(info, action.payload.loadPage);
@ -114,7 +115,7 @@ export class CLNEffects implements OnDestroy {
catchError((err) => {
const code = this.commonService.extractErrorCode(err);
const msg = (code === 'ETIMEDOUT') ? 'Unable to Connect to Core Lightning Server.' : this.commonService.extractErrorMessage(err);
this.router.navigate(['/error'], { state: { errorCode: code, errorMessage: msg } });
this.router.navigate(['/login'], { state: { logoutReason: JSON.stringify(msg) } });
this.handleErrorWithoutAlert('FetchInfo', UI_MESSAGES.GET_NODE_INFO, 'Fetching Node Info Failed.', { status: code, error: msg });
return of({ type: RTLActions.VOID });
})
@ -926,8 +927,7 @@ export class CLNEffects implements OnDestroy {
if (err.status === 401) {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
const errMsg = this.commonService.extractErrorMessage(err, genericErrorMessage);
@ -940,8 +940,8 @@ export class CLNEffects implements OnDestroy {
if (err.status === 401) {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed: ' + err.error }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
const errMsg = this.commonService.extractErrorMessage(err);

@ -787,8 +787,7 @@ export class ECLEffects implements OnDestroy {
if (err.status === 401) {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
this.store.dispatch(updateECLAPICallStatus({ payload: { action: actionName, status: APICallStatusEnum.ERROR, statusCode: err.status.toString(), message: this.commonService.extractErrorMessage(err, genericErrorMessage) } }));
@ -800,8 +799,7 @@ export class ECLEffects implements OnDestroy {
if (err.status === 401) {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
const errMsg = this.commonService.extractErrorMessage(err);

@ -1295,8 +1295,7 @@ export class LNDEffects implements OnDestroy {
if (err.status === 401) {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
this.store.dispatch(updateLNDAPICallStatus({ payload: { action: actionName, status: APICallStatusEnum.ERROR, statusCode: err.status.toString(), message: this.commonService.extractErrorMessage(err, genericErrorMessage) } }));
@ -1308,8 +1307,7 @@ export class LNDEffects implements OnDestroy {
if (err.status === 401) {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
const errMsg = this.commonService.extractErrorMessage(err);

@ -21,10 +21,14 @@
</button>
<mat-error *ngIf="!password">Password is required.</mat-error>
</mat-form-field>
<p *ngIf="loginErrorMessage !== ''" fxFlex="100" class="color-warn pre-wrap" fxLayoutAlign="start start">
<mat-icon class="mr-1 icon-small">close</mat-icon>
<p *ngIf="loginErrorMessage !== ''" class="color-warn pre-wrap" fxFlex="100" fxLayoutAlign="start center">
<mat-icon class="mr-3px icon-small" fxLayoutAlign="center center">close</mat-icon>
{{loginErrorMessage}}
</p>
<p *ngIf="logoutReason !== ''" class="color-warn pre-wrap" fxLayout="row" fxFlex="100" fxLayoutAlign="start center">
<mat-icon class="mr-3px icon-small" fxLayoutAlign="center center">close</mat-icon>
{{logoutReason}}
</p>
<div fxLayout="row" fxFlex="100" fxLayoutAlign="end center" class="mt-2">
<button class="mr-1 mb-2" mat-stroked-button color="primary" tabindex="2" type="reset" (click)="resetData()">Clear</button>
<button mat-flat-button color="primary" tabindex="3" type="submit" (click)="onLogin()">Login</button>

@ -1,13 +1,14 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Subject, combineLatest } from 'rxjs';
import { take, takeUntil } from 'rxjs/operators';
import { filter, take, takeUntil } from 'rxjs/operators';
import * as sha256 from 'sha256';
import { Store } from '@ngrx/store';
import { Actions } from '@ngrx/effects';
import { faUnlockAlt } from '@fortawesome/free-solid-svg-icons';
import { LoginTokenComponent } from '../data-modal/login-2fa-token/login-2fa-token.component';
import { RTLConfiguration } from '../../models/RTLconfig';
import { APICallStatusEnum, PASSWORD_BLACKLIST, ScreenSizeEnum } from '../../services/consts-enums-functions';
import { APICallStatusEnum, PASSWORD_BLACKLIST, RTLActions, ScreenSizeEnum } from '../../services/consts-enums-functions';
import { CommonService } from '../../services/common.service';
import { LoggerService } from '../../services/logger.service';
@ -25,6 +26,7 @@ export class LoginComponent implements OnInit, OnDestroy {
public faUnlockAlt = faUnlockAlt;
public appConfig: RTLConfiguration;
public logoutReason = '';
public password = '';
public rtlSSO = 0;
public rtlCookiePath = '';
@ -36,7 +38,7 @@ export class LoginComponent implements OnInit, OnDestroy {
public apiCallStatusEnum = APICallStatusEnum;
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject()];
constructor(private logger: LoggerService, private store: Store<RTLState>, private rtlEffects: RTLEffects, private commonService: CommonService) { }
constructor(private actions: Actions, private logger: LoggerService, private store: Store<RTLState>, private rtlEffects: RTLEffects, private commonService: CommonService) { }
ngOnInit() {
this.screenSize = this.commonService.getScreenSize();
@ -56,6 +58,10 @@ export class LoginComponent implements OnInit, OnDestroy {
this.appConfig = appConfig;
this.logger.info(appConfig);
});
this.actions.pipe(filter((action) => action.type === RTLActions.LOGOUT), take(1)).
subscribe((action: any) => {
this.logoutReason = action.payload;
});
}
onLogin(): boolean | void {
@ -63,6 +69,7 @@ export class LoginComponent implements OnInit, OnDestroy {
return true;
}
this.loginErrorMessage = '';
this.logoutReason = '';
if (this.appConfig.enable2FA) {
this.store.dispatch(openAlert({
payload: {
@ -87,6 +94,7 @@ export class LoginComponent implements OnInit, OnDestroy {
resetData() {
this.password = '';
this.loginErrorMessage = '';
this.logoutReason = '';
this.flgShow = false;
}

@ -128,7 +128,7 @@ export class SideNavigationComponent implements OnInit, OnDestroy {
subscribe((confirmRes) => {
if (confirmRes) {
this.showLogout = false;
this.store.dispatch(logout());
this.store.dispatch(logout({ payload: '' }));
}
});
}

@ -90,7 +90,7 @@ export class TopMenuComponent implements OnInit, OnDestroy {
subscribe((confirmRes) => {
if (confirmRes) {
this.showLogout = false;
this.store.dispatch(logout());
this.store.dispatch(logout({ payload: '' }));
}
});
}

@ -98,7 +98,7 @@ export class BoltzService implements OnDestroy {
if (err.status === 401) {
errMsg = 'Unauthorized User.';
this.logger.info('Redirecting to Login');
this.store.dispatch(logout());
this.store.dispatch(logout({ payload: errMsg }));
} else if (err.status === 503) {
errMsg = 'Unable to Connect to Boltz Server.';
this.store.dispatch(openAlert({
@ -121,14 +121,14 @@ export class BoltzService implements OnDestroy {
let errMsg = '';
if (err.status === 401) {
this.logger.info('Redirecting to Login');
this.store.dispatch(logout());
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
}
this.logger.error(err);
this.store.dispatch(closeSpinner({ payload: uiMessage }));
if (err.status === 401) {
errMsg = 'Unauthorized User.';
this.logger.info('Redirecting to Login');
this.store.dispatch(logout());
this.store.dispatch(logout({ payload: errMsg }));
} else if (err.status === 503) {
errMsg = 'Unable to Connect to Boltz Server.';
setTimeout(() => {

@ -418,8 +418,7 @@ export class DataService implements OnDestroy {
if (err.status === 401) {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
this.store.dispatch(updateRootAPICallStatus({ payload: { action: actionName, status: APICallStatusEnum.ERROR, statusCode: err.status.toString(), message: this.extractErrorMessage(err) } }));
@ -431,8 +430,7 @@ export class DataService implements OnDestroy {
if (err.status === 401) {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
const errMsg = this.extractErrorMessage(err);

@ -145,7 +145,7 @@ export class LoopService implements OnDestroy {
if (err.status === 401) {
errMsg = 'Unauthorized User.';
this.logger.info('Redirecting to Login');
this.store.dispatch(logout());
this.store.dispatch(logout({ payload: errMsg }));
} else if (err.status === 503) {
errMsg = 'Unable to Connect to Loop Server.';
this.store.dispatch(openAlert({
@ -171,7 +171,7 @@ export class LoopService implements OnDestroy {
if (err.status === 401) {
errMsg = 'Unauthorized User.';
this.logger.info('Redirecting to Login');
this.store.dispatch(logout());
this.store.dispatch(logout({ payload: errMsg }));
} else if (err.status === 503) {
errMsg = 'Unable to Connect to Loop Server.';
setTimeout(() => {

@ -50,7 +50,7 @@ export const updateApplicationSettings = createAction(RTLActions.UPDATE_APPLICAT
export const setNodeData = createAction(RTLActions.SET_NODE_DATA, props<{ payload: GetInfoRoot }>());
export const logout = createAction(RTLActions.LOGOUT);
export const logout = createAction(RTLActions.LOGOUT, props<{ payload: string }>());
export const resetPassword = createAction(RTLActions.RESET_PASSWORD, props<{ payload: ResetPassword }>());

@ -383,7 +383,7 @@ export class RTLEffects implements OnDestroy {
if (+appConfig.SSO.rtlSSO) {
this.router.navigate(['/error'], { state: { errorCode: '406', errorMessage: err.error && err.error.error ? err.error.error : 'Single Sign On Failed!' } });
} else {
this.router.navigate(['./login']);
this.router.navigate(['./login'], { state: { logoutReason: err.error && err.error.error ? err.error.error : 'Single Sign On Failed!' } });
}
return of({ type: RTLActions.VOID });
}));
@ -418,12 +418,13 @@ export class RTLEffects implements OnDestroy {
logOut = createEffect(
() => this.actions.pipe(
ofType(RTLActions.LOGOUT),
mergeMap((appConfig: RTLConfiguration) => {
withLatestFrom(this.store.select(rootAppConfig)),
mergeMap(([action, appConfig]: [{ type: string, payload: string }, RTLConfiguration]) => {
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.LOG_OUT }));
if (appConfig.SSO && +appConfig.SSO.rtlSSO) {
window.location.href = appConfig.SSO.logoutRedirectLink;
} else {
this.router.navigate(['./login']);
this.router.navigate(['./login'], { state: { logoutReason: action.payload } });
}
this.sessionService.clearAll();
this.store.dispatch(setNodeData({ payload: {} }));
@ -580,8 +581,7 @@ export class RTLEffects implements OnDestroy {
if (err.status === 401 && actionName !== 'Login') {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
this.store.dispatch(updateRootAPICallStatus({ payload: { action: actionName, status: APICallStatusEnum.ERROR, statusCode: err.status ? err.status.toString() : '', message: this.commonService.extractErrorMessage(err) } }));
@ -596,8 +596,7 @@ export class RTLEffects implements OnDestroy {
if (err.status === 401 && actionName !== 'Login') {
this.logger.info('Redirecting to Login');
this.store.dispatch(closeAllDialogs());
this.store.dispatch(logout());
this.store.dispatch(openSnackBar({ payload: 'Authentication Failed. Redirecting to Login.' }));
this.store.dispatch(logout({ payload: 'Authentication Failed: ' + JSON.stringify(err.error) }));
} else {
this.store.dispatch(closeSpinner({ payload: uiMessage }));
const errMsg = this.commonService.extractErrorMessage(err);

Loading…
Cancel
Save