Sign-up in UI to Back-end
This commit is contained in:
parent
f1eb8da2d6
commit
f7eb8bc9b9
BIN
CezenLogo/Mathews.jpg
Normal file
BIN
CezenLogo/Mathews.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 436 KiB |
BIN
CezenLogo/mathewes.jpg
Normal file
BIN
CezenLogo/mathewes.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 372 KiB |
BIN
CezenLogo/mathews_final_db.jpg
Normal file
BIN
CezenLogo/mathews_final_db.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 372 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,5 @@
|
|||||||
|
import { createUserNewAdmin } from "../../http_routs/userHttp";
|
||||||
|
|
||||||
export default function SignUp() {
|
export default function SignUp() {
|
||||||
function onSubmitLoginForm(event) {
|
function onSubmitLoginForm(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -6,6 +8,17 @@ export default function SignUp() {
|
|||||||
const data = Object.fromEntries(formData.entries());
|
const data = Object.fromEntries(formData.entries());
|
||||||
|
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
const responseData = createUserNewAdmin(data);
|
||||||
|
|
||||||
|
responseData.then((data) => {
|
||||||
|
console.log("Thenable");
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
// if the return status is false then update the ui accordingly
|
||||||
|
if (!data?.status) {
|
||||||
|
console.log("Error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// event.target.reset();
|
// event.target.reset();
|
||||||
}
|
}
|
||||||
@ -17,10 +30,10 @@ export default function SignUp() {
|
|||||||
<div className="form-elements">
|
<div className="form-elements">
|
||||||
<div>
|
<div>
|
||||||
<label>user name</label>
|
<label>user name</label>
|
||||||
<input name="user_name" />
|
<input name="userName" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label>email</label>
|
<label>Recovery Email</label>
|
||||||
<input name="email" />
|
<input name="email" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -29,7 +42,7 @@ export default function SignUp() {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label>confirm password</label>
|
<label>confirm password</label>
|
||||||
<input name="confirm_password" />
|
<input name="confirmPassword" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button>Sign Up</button>
|
<button>Sign Up</button>
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const protocol = "http";
|
||||||
|
const domainNameOrIp = "127.0.0.1";
|
||||||
|
const portNumber = "8081";
|
||||||
|
|
||||||
|
export default `${protocol}://${domainNameOrIp}:${portNumber}`;
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
import socket from "./httpDomainName";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this is used to send the data collected from
|
||||||
|
* the signup form to the backend
|
||||||
|
* in turn it creates the user
|
||||||
|
* returns a return status with true if created
|
||||||
|
* false if there was an error if any kind
|
||||||
|
*/
|
||||||
|
export async function createUserNewAdmin(signUpObject = {}) {
|
||||||
|
// returns a promise we use await to get the response body using JSON()
|
||||||
|
const response = await fetch(`${socket}/open/signup`, {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(signUpObject),
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const resData = await response.json();
|
||||||
|
|
||||||
|
// console.log("response data");
|
||||||
|
// console.log(resData);
|
||||||
|
|
||||||
|
return resData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method is used to log-in
|
||||||
|
* it uses the basic auth log-in technique
|
||||||
|
* if successful a JWT token will be returned from the backend
|
||||||
|
* use the JWT token for every subsequent request
|
||||||
|
*/
|
||||||
@ -51,8 +51,8 @@ public class CezenLoginSecurityChain {
|
|||||||
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
|
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
|
||||||
//check CORs and CSRF in Previous commits
|
//check CORs and CSRF in Previous commits
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
CorsConfiguration config = new CorsConfiguration();
|
||||||
// config.setAllowedOrigins(Collections.singletonList("http://localhost:4200"));
|
config.setAllowedOrigins(Collections.singletonList("http://localhost:5173"));
|
||||||
config.setAllowedOrigins(Collections.singletonList("*"));
|
//config.setAllowedOrigins(Collections.singletonList("*"));
|
||||||
config.setAllowedMethods(Collections.singletonList("*"));
|
config.setAllowedMethods(Collections.singletonList("*"));
|
||||||
config.setAllowCredentials(true);
|
config.setAllowCredentials(true);
|
||||||
config.setAllowedHeaders(Collections.singletonList("*"));
|
config.setAllowedHeaders(Collections.singletonList("*"));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user