JS class refactor for user login
@ -54,7 +54,7 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
react_app:
|
react_app:
|
||||||
image: mathewfrancisv/cezen_react:v1.0.0
|
image: mathewfrancisv/cezen_react:v2.0.0
|
||||||
container_name: react_cezenpbx
|
container_name: react_cezenpbx
|
||||||
restart: always
|
restart: always
|
||||||
working_dir: /app
|
working_dir: /app
|
||||||
|
|||||||
0
MySQL_conf_pbx/test1/reactcezenpbx/.gitignore
vendored
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/README.md
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/eslint.config.js
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/index.html
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/package-lock.json
generated
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/package.json
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/public/CezenLogo.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/public/CezenLogobig.png
Normal file → Executable file
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/public/CezenLogobig.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/public/cezen_home_icon.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/public/file.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/public/lite1.png
Normal file → Executable file
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/public/vite.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/src/App.css
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/App.jsx
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/assets/CezenLogo.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/src/assets/hammer-spanner-svgrepo-com.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/src/assets/profile-circle-svgrepo-com.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 748 B After Width: | Height: | Size: 748 B |
0
MySQL_conf_pbx/test1/reactcezenpbx/src/assets/react.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
0
MySQL_conf_pbx/test1/reactcezenpbx/src/components/landing-page/home-page.css
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/components/landing-page/homePage.jsx
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/components/landing-page/navBar.jsx
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/components/landing-page/navStyleImpl.css
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/components/login-logout/cezenBanar.jsx
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/components/login-logout/form_styling.css
Normal file → Executable file
4
MySQL_conf_pbx/test1/reactcezenpbx/src/components/login-logout/logIn.jsx
Normal file → Executable file
@ -1,4 +1,4 @@
|
|||||||
import { userLogin } from "../../http_routs/userHttp";
|
import { userLoginAndResp } from "../../http_routs/userHttp";
|
||||||
|
|
||||||
export default function LogIn() {
|
export default function LogIn() {
|
||||||
function logInFunction(event) {
|
function logInFunction(event) {
|
||||||
@ -9,7 +9,7 @@ export default function LogIn() {
|
|||||||
const data = Object.fromEntries(formData.entries());
|
const data = Object.fromEntries(formData.entries());
|
||||||
|
|
||||||
console.log(data);
|
console.log(data);
|
||||||
userLogin(data.user_name, data.password);
|
userLoginAndResp(data.user_name, data.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
0
MySQL_conf_pbx/test1/reactcezenpbx/src/components/login-logout/logo_and_text.css
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/components/login-logout/signInup.jsx
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/components/login-logout/signUp.jsx
Normal file → Executable file
0
MySQL_conf_pbx/test1/reactcezenpbx/src/http_routs/httpDomainName.js
Normal file → Executable file
73
MySQL_conf_pbx/test1/reactcezenpbx/src/http_routs/userHttp.js
Normal file → Executable file
@ -33,20 +33,69 @@ export async function createUserNewAdmin(signUpObject = {}) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//user login data
|
//user login data
|
||||||
export async function userLogin(username, password) {
|
// export async function userLogin(username, password) {
|
||||||
|
// //make an http get request for userLogin login
|
||||||
|
|
||||||
|
// const loginResp = await fetch(`${socket}/open/login`, {
|
||||||
|
// method: `GET`,
|
||||||
|
// headers: basicAuthCredentialsBuilder(username, password),
|
||||||
|
// credentials: "include", // <-- VERY IMPORTANT to get the JWT cookie from the backend
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const resData = await loginResp.json();
|
||||||
|
|
||||||
|
// console.log("response data");
|
||||||
|
// console.log(resData);
|
||||||
|
|
||||||
|
// return loginResp;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //common basic auth header builder
|
||||||
|
// function basicAuthCredentialsBuilder(username, password) {
|
||||||
|
// //builds the appropriate format for basic auth
|
||||||
|
// return {
|
||||||
|
// Authorization: "Basic " + window.btoa(username + ":" + password),
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
|
export async function userLoginAndResp(username, password) {
|
||||||
//make an http get request for userLogin login
|
//make an http get request for userLogin login
|
||||||
|
|
||||||
const loginResp = await fetch(`${socket}/open/login`, {
|
const auth = new authenticationBuilder(socket);
|
||||||
method: `GET`,
|
|
||||||
headers: basicAuthCredentialsBuilder(username, password),
|
return auth.userLogin(username, password);
|
||||||
credentials: "include", // <-- VERY IMPORTANT
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//common basic auth header builder
|
/**
|
||||||
function basicAuthCredentialsBuilder(username, password) {
|
* This class helps the user login
|
||||||
//builds the appropriate format for basic auth
|
*/
|
||||||
return {
|
class authenticationBuilder {
|
||||||
Authorization: "Basic " + window.btoa(username + ":" + password),
|
#socketURL = "";
|
||||||
};
|
|
||||||
|
constructor(socketURL) {
|
||||||
|
this.#socketURL = socketURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
async userLogin(username, password) {
|
||||||
|
//make an http get request for userLogin login
|
||||||
|
const loginResp = await fetch(`${this.#socketURL}/open/login`, {
|
||||||
|
method: `GET`,
|
||||||
|
headers: this.#basicAuthCredentialsBuilder(username, password),
|
||||||
|
credentials: "include", // <-- VERY IMPORTANT to get the JWT cookie from the backend
|
||||||
|
});
|
||||||
|
|
||||||
|
const resData = await loginResp.json();
|
||||||
|
|
||||||
|
console.log("response data");
|
||||||
|
console.log(resData);
|
||||||
|
|
||||||
|
return loginResp;
|
||||||
|
}
|
||||||
|
|
||||||
|
#basicAuthCredentialsBuilder(username, password) {
|
||||||
|
//builds the appropriate format for basic auth
|
||||||
|
return {
|
||||||
|
Authorization: "Basic " + window.btoa(username + ":" + password),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||