Skip to content
Snippets Groups Projects
Commit c058a04e authored by Sarthak Shrivastava's avatar Sarthak Shrivastava
Browse files

working version, may need to adjust schema and password to run locally

parent 503a79e8
No related branches found
No related tags found
No related merge requests found
......@@ -7,12 +7,22 @@ export const DeleteUser = () => {
const handleSubmit = (e) => {
e.preventDefault();
Axios.post("http://localhost:8080/user/delete", {
email: email,
Axios.delete("http://localhost:8080/user/delete", {
headers: {},
data: {
email: email
}
}).then((response) => {
console.log(response);
});
};
};
// Axios.delete("http://localhost:8080/user/delete", {
// email: email,
// }).then((response) => {
// console.log(response);
// });
// };
return (
<div className="auth-form-container">
......
import React, { useState } from "react";
import Axios from "axios";
export const Login = (props) => {
const [email, setEmail] = useState("");
......@@ -8,6 +9,7 @@ export const Login = (props) => {
e.preventDefault();
console.log(email);
console.log(pass);
};
return (
......
......@@ -10,7 +10,6 @@ export const Register = (props) => {
const handleSubmit = (e) => {
e.preventDefault();
Axios.post("http://localhost:8080/user/add", {
email: email,
lname: lname,
......
......@@ -8,7 +8,7 @@ export const UpdatePassword = () => {
const handleSubmit = (e) => {
e.preventDefault();
Axios.post("http://localhost:8080/user/updatepass", {
Axios.put("http://localhost:8080/user/changepass", {
email: email,
password: pass,
}).then((response) => {
......
......@@ -9,7 +9,8 @@ import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.Optional;
@Controller // This means that this class is a Controller
@CrossOrigin
@RestController // This means that this class is a Controller
@RequestMapping(path="/user") // This means URL's start with /demo (after Application path)
public class MainController {
@Autowired // This means to get the bean called userRepository
......@@ -60,18 +61,27 @@ public class MainController {
}
@GetMapping(path = "/user")
public @ResponseBody Optional<User> getUser(@RequestBody String email)
public @ResponseBody Optional<User> getUser(@RequestBody Map<String, String> json)
{
String email = json.get("email");
return userRepository.findById(email);
}
@DeleteMapping(path = "/delete")
public @ResponseBody User deleteUser(@RequestBody String email)
public @ResponseBody User deleteUser(@RequestBody Map<String, String> json)
{
User found = null;
found = userRepository.findById(email).get();
if (found != null)
String email = json.get("email");
Optional<User> optionalUser = userRepository.findById(email);
if (optionalUser.isPresent())
{
System.out.println("in if statement");
found = optionalUser.get();
userRepository.deleteById(email);
return found;
return found;
}
return null;
}
}
\ No newline at end of file
......@@ -31,11 +31,11 @@ public class User {
this.password = password;
}
public Integer getPhoneNumber() {
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(Integer phoneNumber) {
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
......@@ -46,7 +46,7 @@ public class User {
private String password;
private Integer phoneNumber;
private String phoneNumber;
@Id
@Column(nullable = false)
......
......@@ -2,6 +2,6 @@
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/inventory
spring.datasource.username=root
spring.datasource.password=czarthak
spring.datasource.password=CSD@mysql-1872
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.jpa.show-sql: true
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment