From 22f46999d33341b2d4963a2b04e13547aeb5d0a4 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Tue, 16 Feb 2021 16:42:11 +0000 Subject: [PATCH] updates --- .vscode/launch.json | 4 +-- client/src/App.js | 53 +++++++++++++++++++++++++++++++++++--- client/src/app2.js | 60 ++++++++++++++++++++++++++++++++++++++++++++ lib/addAccounts.js | 42 ++++++++++++++++++------------- lib/streamArray.json | 2 +- package-lock.json | 13 ++++++++++ package.json | 1 + 7 files changed, 152 insertions(+), 23 deletions(-) create mode 100644 client/src/app2.js diff --git a/.vscode/launch.json b/.vscode/launch.json index 3efaad1..0345b3f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "React", "type": "chrome", "request": "launch", - "url": "http://localhost:3000", + "url": "http://localhost:6969", "webRoot": "${workspaceRoot}/react-backend/client/src" }, { @@ -36,7 +36,7 @@ "skipFiles": [ "/**" ], - "program": "${workspaceFolder}/lib/encrypt.js" + "program": "${workspaceFolder}/lib/addAccounts.js" } ] } \ No newline at end of file diff --git a/client/src/App.js b/client/src/App.js index a1960de..4fd2c4c 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,22 +1,69 @@ import React, { Component } from 'react'; +import axios from 'axios'; import './App.css'; class App extends Component { - state = { streams: [] } + constructor() { + super(); + this.state = { + fname: '', + lname: '', + streams: [] + }; + } + + componentDidMount() { fetch('/getStreams') .then(res => res.json()) .then(streams => this.setState({ streams })); } + + + onChange = (e) => { + /* + Because we named the inputs to match their + corresponding values in state, it's + super easy to update the state + */ + this.setState({ [e.target.name]: e.target.value }); + } + + onSubmit = (e) => { + e.preventDefault(); + // get our form data out of state + const { fname, lname } = this.state; + console.log({ fname, lname }) + } + render() { + const { fname, lname } = this.state; return (

User Login

- I am a user login +

+

UserName + +

+

Password + +

+
+ +

-
diff --git a/client/src/app2.js b/client/src/app2.js new file mode 100644 index 0000000..b2b761b --- /dev/null +++ b/client/src/app2.js @@ -0,0 +1,60 @@ +import React, { Component } from 'react'; +import axios from 'axios'; + +class UserForm extends Component { + constructor() { + super(); + this.state = { + fname: '', + lname: '', + email: '', + }; + } + + onChange = (e) => { + /* + Because we named the inputs to match their + corresponding values in state, it's + super easy to update the state + */ + this.setState({ [e.target.name]: e.target.value }); + } + + onSubmit = (e) => { + e.preventDefault(); + // get our form data out of state + const { fname, lname, email } = this.state; + + axios.post('/', { fname, lname, email }) + .then((result) => { + //access the results here.... + }); + } + + render() { + const { fname, lname, email } = this.state; + return ( +
+ + + + +
+ ); + } +} \ No newline at end of file diff --git a/lib/addAccounts.js b/lib/addAccounts.js index d1d3fc6..cd6b7ac 100644 --- a/lib/addAccounts.js +++ b/lib/addAccounts.js @@ -4,33 +4,41 @@ const cryptr = new Cryptr('BBLBTV-DNS-PASSWORDS'); const sql = require('./mysql') function storeAccountToDB(accountDetails) { - const encryptedPassword = cryptr.encrypt(accountDetails.password); - const result = sql.query(`INSERT userAccounts (username, password, stream, userID) VALUES ("${accountDetails.username}", "${encryptedPassword}", "${accountDetails.stream}", ${accountDetails.userId})`); - // console.log(result) - return result + const encryptedPassword = cryptr.encrypt(accountDetails.password); + const result = sql.query(`INSERT userAccounts (username, password, stream, userID) VALUES ("${accountDetails.username}", "${encryptedPassword}", "${accountDetails.stream}", ${accountDetails.userId})`); + return result } function retrievePasswordFromDB(user, userAccUser) { - let userId = sql.query(`SELECT u.idusers FROM users u WHERE u.userName = '${user}'`); + let userId + try { + userId = sql.query(`SELECT u.idusers FROM users u WHERE u.userName = '${user}'`); userId = userId[0].idusers + } catch (error) { + console.log('User not found') + return (error) + } - let accountPassword = sql.query(`SELECT DISTINCT - userAccounts.username, - userAccounts.password, - userAccounts.userID - FROM users, - userAccounts, - streams - WHERE userAccounts.userID = ${userId} AND userAccounts.username = '${userAccUser}'`) + let accountPassword + accountPassword = sql.query(`SELECT DISTINCT + userAccounts.username, + userAccounts.password, + userAccounts.userID +FROM users, + userAccounts, + streams +WHERE userAccounts.userID = ${userId} AND userAccounts.username = '${userAccUser}'`) + + if (accountPassword == 0) { + throw new Error('Account ' + userAccUser + ' not found for user ' + user) + } else { const decryptedString = cryptr.decrypt(accountPassword[0].password); console.log(decryptedString) - + } } -// storePasswordToDB('kcshkzex') - -// retrievePasswordFromDB('Karl', 'Karl0820') +retrievePasswordFromDB('Karl', 'Karl2903') module.exports = { storeAccountToDB, diff --git a/lib/streamArray.json b/lib/streamArray.json index f74a7fc..6ef176f 100644 --- a/lib/streamArray.json +++ b/lib/streamArray.json @@ -1 +1 @@ -[{"StreamName":"Insanity","StreamURL":"https://trippy.pro:443"},{"StreamName":"PremPlus","StreamURL":"https://itty.in:443"},{"StreamName":"GunSlinger","StreamURL":"http://gunslingertv.org:8080"},{"StreamName":"VIP","StreamURL":"http://oven-cleaner.com:8080/"},{"StreamName":"Technoid","StreamURL":"http://capoisagod2021.org:8080"},{"StreamName":"Old Premium","StreamURL":"https://caporeds.online:443","username":"Dazg3012","expiaryDate":"12/30/2021"},{"StreamName":"??","StreamURL":"http://screamstreams.info:8080"},{"StreamName":"Gold","StreamURL":"http://catenamode.cf:8090"},{"StreamName":"??","StreamURL":"http://sulu.xyz:2086"},{"StreamName":"??","StreamURL":"http://bigbox.me.uk:2086"},{"StreamName":"??","StreamURL":"http://beautifilm.xyz:8080"},{"StreamName":"??","StreamURL":"https://hulks.xyz:443"},{"StreamName":"??","StreamURL":"http://mytv.digital:8080/"},{"StreamName":"??","StreamURL":"http://theonlinemedia.network:2052"},{"StreamName":"Gold","StreamURL":"http://server1.jforbes.club:8090"},{"StreamName":"??","StreamURL":"http://ths.viewdns.net:8080"},{"StreamName":"??","StreamURL":"http://vpsuk.store:8080"},{"StreamName":"??","StreamURL":"http://ac.mustardsubs.tk:8880"},{"StreamName":"??","StreamURL":"http://faithhosting.xyz:25461"},{"StreamName":"??","StreamURL":"http://ip365.cx:80"},{"StreamName":"??","StreamURL":"http://g132.caporeds.online:8080/"},{"StreamName":"??","StreamURL":"http://theonlinemedia.network:2052"},{"StreamName":"??","StreamURL":"http://beautifilm.xyz:8080"},{"StreamName":"??","StreamURL":"http://pimptv.dnsabr.com:8080"},{"StreamName":"??","StreamURL":"http://tavaratv.xyz:2095"},{"StreamName":"??","StreamURL":"http://cms-tan.media:8880"},{"StreamName":"??","StreamURL":"http://streamknighttv.xyz:8080"},{"StreamName":"??","StreamURL":"http://covidsucks.xyz:8080"},{"StreamName":"??","StreamURL":"http://fckbrexit.link:8080"},{"StreamName":"Gambler","StreamURL":"http://tv.realot.xyz:35001"},{"StreamName":"??","StreamURL":"http://www.tvxclnt.com:8080"},{"StreamName":"??","StreamURL":"http://iptv.satplex.co.uk:8080"},{"StreamName":"??","StreamURL":"http://37723998.to:2052"}] \ No newline at end of file +[{"StreamName":"Insanity","StreamURL":"https://trippy.pro:443"},{"StreamName":"PremPlus","StreamURL":"https://itty.in:443"},{"StreamName":"GunSlinger","StreamURL":"http://gunslingertv.org:8080"},{"StreamName":"VIP","StreamURL":"http://oven-cleaner.com:8080/"},{"StreamName":"Technoid","StreamURL":"http://capoisagod2021.org:8080"},{"StreamName":"Old Premium","StreamURL":"https://caporeds.online:443","username":"Dazg3012","expiaryDate":"12/30/2021"},{"StreamName":"??","StreamURL":"http://screamstreams.info:8080"},{"StreamName":"Gold","StreamURL":"http://catenamode.cf:8090"},{"StreamName":"??","StreamURL":"http://sulu.xyz:2086"},{"StreamName":"??","StreamURL":"http://bigbox.me.uk:2086"},{"StreamName":"??","StreamURL":"http://beautifilm.xyz:8080"},{"StreamName":"??","StreamURL":"https://hulks.xyz:443"},{"StreamName":"??","StreamURL":"http://mytv.digital:8080/"},{"StreamName":"??","StreamURL":"http://theonlinemedia.network:2052"},{"StreamName":"Gold","StreamURL":"http://server1.jforbes.club:8090"},{"StreamName":"??","StreamURL":"http://ths.viewdns.net:8080"},{"StreamName":"??","StreamURL":"http://vpsuk.store:8080"},{"StreamName":"??","StreamURL":"http://ac.mustardsubs.tk:8880"},{"StreamName":"??","StreamURL":"http://faithhosting.xyz:25461"},{"StreamName":"??","StreamURL":"http://ip365.cx:80"},{"StreamName":"??","StreamURL":"https://trippy.pro:443"},{"StreamName":"??","StreamURL":"http://g132.caporeds.online:8080/"},{"StreamName":"??","StreamURL":"http://theonlinemedia.network:2052"},{"StreamName":"??","StreamURL":"http://beautifilm.xyz:8080"},{"StreamName":"??","StreamURL":"http://pimptv.dnsabr.com:8080"},{"StreamName":"??","StreamURL":"http://tavaratv.xyz:2095"},{"StreamName":"??","StreamURL":"http://cms-tan.media:8880"},{"StreamName":"??","StreamURL":"http://streamknighttv.xyz:8080"},{"StreamName":"??","StreamURL":"http://covidsucks.xyz:8080"},{"StreamName":"Gambler","StreamURL":"http://fckbrexit.link:8080"},{"StreamName":"??","StreamURL":"http://tv.realot.xyz:35001"},{"StreamName":"??","StreamURL":"http://www.tvxclnt.com:8080"},{"StreamName":"??","StreamURL":"http://iptv.satplex.co.uk:8080"}] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index fea56bf..7a0d900 100644 --- a/package-lock.json +++ b/package-lock.json @@ -125,6 +125,14 @@ "resolved": "https://registry.npmjs.org/asap/-/asap-1.0.0.tgz", "integrity": "sha1-sqRdpf36ILBJb8N2jMJ8EvqRan0=" }, + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "babel-runtime": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", @@ -546,6 +554,11 @@ "unpipe": "~1.0.0" } }, + "follow-redirects": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.2.tgz", + "integrity": "sha512-6mPTgLxYm3r6Bkkg0vNM0HTjfGrOEtsfbhagQvbxDEsEkpNhw582upBaoRZylzen6krEmxXJgt9Ju6HiI4O7BA==" + }, "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", diff --git a/package.json b/package.json index e71376b..9f0f9b5 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "start": "node ./bin/www" }, "dependencies": { + "axios": "^0.21.1", "bcrypt": "^5.0.0", "cookie-parser": "~1.4.4", "cryptr": "^6.0.2",