mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-22 14:22:33 +01:00
chore: fix auth encoding
This commit is contained in:
parent
388f0343ee
commit
bf5b7d4250
2 changed files with 13 additions and 12 deletions
|
@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';
|
||||||
import { useAccount } from '../../context/AccountContext';
|
import { useAccount } from '../../context/AccountContext';
|
||||||
import { saveUserAuth, getAuthString, saveSessionAuth } from '../../utils/auth';
|
import { saveUserAuth, getAuthString, saveSessionAuth } from '../../utils/auth';
|
||||||
import CryptoJS from 'crypto-js';
|
import CryptoJS from 'crypto-js';
|
||||||
import base64url from 'base64url';
|
|
||||||
import { PasswordInput } from './Password';
|
import { PasswordInput } from './Password';
|
||||||
import { useLazyQuery } from '@apollo/react-hooks';
|
import { useLazyQuery } from '@apollo/react-hooks';
|
||||||
import { GET_CAN_CONNECT } from '../../graphql/query';
|
import { GET_CAN_CONNECT } from '../../graphql/query';
|
||||||
|
@ -63,9 +62,9 @@ export const LoginForm = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loading && data && data.getNodeInfo && data.getNodeInfo.alias) {
|
if (!loading && data && data.getNodeInfo && data.getNodeInfo.alias) {
|
||||||
const admin = base64url.fromBase64(isAdmin);
|
const admin = isAdmin;
|
||||||
const read = base64url.fromBase64(isRead);
|
const read = isRead;
|
||||||
const cert = base64url.fromBase64(isCert);
|
const cert = isCert;
|
||||||
|
|
||||||
const encryptedAdmin =
|
const encryptedAdmin =
|
||||||
admin && isPass !== ''
|
admin && isPass !== ''
|
||||||
|
@ -114,9 +113,9 @@ export const LoginForm = ({
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleConnect = () => {
|
const handleConnect = () => {
|
||||||
const admin = base64url.fromBase64(isAdmin);
|
const admin = isAdmin;
|
||||||
const read = base64url.fromBase64(isRead);
|
const read = isRead;
|
||||||
const cert = base64url.fromBase64(isCert);
|
const cert = isCert;
|
||||||
|
|
||||||
const correctMacaroon = read ? read : admin;
|
const correctMacaroon = read ? read : admin;
|
||||||
|
|
||||||
|
|
|
@ -74,13 +74,15 @@ export const getAuthLnd = (lndconnect: string) => {
|
||||||
const macaroon = url.searchParams.get('macaroon') || '';
|
const macaroon = url.searchParams.get('macaroon') || '';
|
||||||
const socket = url.host;
|
const socket = url.host;
|
||||||
|
|
||||||
return { cert, macaroon, socket };
|
return {
|
||||||
|
cert: base64url.toBase64(cert),
|
||||||
|
macaroon: base64url.toBase64(macaroon),
|
||||||
|
socket,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBase64CertfromDerFormat = (url: string) => {
|
export const getBase64CertfromDerFormat = (base64: string) => {
|
||||||
if (!url) return null;
|
if (!base64) return null;
|
||||||
|
|
||||||
const base64 = base64url.toBase64(url);
|
|
||||||
|
|
||||||
const prefix = '-----BEGIN CERTIFICATE-----\n';
|
const prefix = '-----BEGIN CERTIFICATE-----\n';
|
||||||
const postfix = '-----END CERTIFICATE-----';
|
const postfix = '-----END CERTIFICATE-----';
|
||||||
|
|
Loading…
Add table
Reference in a new issue