Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prithvi 7 #22

Merged
merged 2 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.masai.entity.Customer;
import com.masai.entity.SubscribedEmail;
import com.masai.service.CustomerOps;

import jakarta.validation.Valid;
import lombok.val;

@RestController
//@CrossOrigin(origins = "*")
Expand Down Expand Up @@ -65,6 +63,6 @@ public ResponseEntity<List<Customer>> viewAllCustomer(){

@PostMapping("/subscriber")
public ResponseEntity<String> subscribe(@Valid @RequestBody SubscribedEmail se){
return new ResponseEntity<>("Subscribed!",HttpStatus.OK);
return new ResponseEntity<>(co.subsCustomer(se),HttpStatus.OK);
}
}
4 changes: 2 additions & 2 deletions Backend/src/main/java/com/masai/entity/Customer.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.masai.entity;
package com.masai.entity;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -55,7 +55,7 @@ public class Customer {
private boolean status;
@NotBlank(message = "Please provide the customer password")
@NotNull(message = "Please provide the customer password")
@Size(min = 10, max = 10, message = "min 10 and max 10 characters allowed only")
// @Size(min = 10, max = 10, message = "min 10 and max 10 characters allowed only")
private String mobileNo;

@Email(message = "email is not in correct format")
Expand Down
4 changes: 2 additions & 2 deletions Backend/src/main/java/com/masai/security/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
});

}).authorizeHttpRequests(auth -> {
auth.requestMatchers("/**").permitAll();
auth.requestMatchers(HttpMethod.POST, "travel/customer/signup", "travel/addAdmin").permitAll()
// auth.requestMatchers("/**").permitAll();
auth.requestMatchers(HttpMethod.POST, "travel/customer/signup", "travel/addAdmin","travel/subscriber").permitAll()

.requestMatchers(HttpMethod.POST, "travel/updateAdmin", "travel/adddestination",
"travel/bus", "travel/bus/travels", "travel/destination",
Expand Down
35 changes: 25 additions & 10 deletions Backend/src/main/java/com/masai/service/CustomerOpsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,32 @@ public Customer addCustomer(Customer customer) {
if(customer.getRole()==null){
customer.setRole("ROLE_USER");
}
if(customer.getRole().equals("ADMIN")){
customer.setRole("ROLE_ADMIN");
}else if(customer.getRole().equals("USER")){
else {
customer.setRole("ROLE_USER");
}else if(customer.getRole().equals("ROLE_USER")){
customer.setRole("ROLE_USER");
}else if(customer.getRole().equals("ROLE_ADMIN")){
customer.setRole("ROLE_ADMIN");
}else{
customer.setRole("ROLE_USER");
}
}
List<Customer> list= viewAllCustomer();

list.forEach(data->{
if(data.getEmail().equals((customer.getEmail())))
throw new EntityAlreadyAlteredException("Customer already registered");
});

return cd.save(customer);
// if(customer.getRole().equals("ADMIN")){
// customer.setRole("ROLE_ADMIN");
// }
// else if(customer.getRole().equals("USER")){
// customer.setRole("ROLE_USER");
// }
// else if(customer.getRole().equals("ROLE_USER")){
// customer.setRole("ROLE_USER");
// }
// else if(customer.getRole().equals("ROLE_ADMIN")){
// customer.setRole("ROLE_ADMIN");
// }
// else{
// customer.setRole("ROLE_USER");
// }

}

Expand All @@ -58,6 +72,7 @@ public Customer updateCustomer(Integer cid,Customer cus) {
if (!cus.isStatus()) {
throw new EntityAlreadyAlteredException("Unable to update already deleted customer");
}

customer.setCustomerName(cus.getCustomerName());
customer.setCustomerPassword(cus.getCustomerPassword());
customer.setAddress(cus.getAddress());
Expand Down
7 changes: 3 additions & 4 deletions Frontend/CSS/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,11 @@ bottom1 {
}
#notify {
border: 2px solid black;
width: 25%;
right: 37.5%;
margin: auto;
width: 20%;
font-style: italic;
text-align: center;
color: brown;
position: absolute;
font-weight: bolder;
background-color: #e1f5fe;
border-radius: 10px;
Expand All @@ -544,7 +544,6 @@ bottom1 {
border: none;
opacity: 0;
padding: 6px;

/* border: 2px solid brown; */
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
}
10 changes: 5 additions & 5 deletions Frontend/CSS/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ div h3 {
padding: 20px;
text-align: center;
position: absolute;
top: 20%;
top: 24%;
right: 6%;
background: #e1f5fe;
border-radius: 7px;
Expand Down Expand Up @@ -379,11 +379,11 @@ div h3 {
}
#notify {
border: 2px solid black;
width: 25%;
right: 37.5%;
margin: auto;
width: 20%;
font-style: italic;
text-align: center;
color: brown;
position: absolute;
font-weight: bolder;
background-color: #e1f5fe;
border-radius: 10px;
Expand All @@ -402,7 +402,7 @@ div h3 {
/* margin: auto; */
position: absolute;
right: 25%;
bottom: 45%;
bottom: 44%;
background-color: #e1f5fe;
display: grid;
grid-template-columns: repeat(2, 1fr);
Expand Down
6 changes: 3 additions & 3 deletions Frontend/CSS/user.css
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,11 @@ bottom1 {
}
#notify {
border: 2px solid black;
width: 25%;
right: 37.5%;
margin: auto;
width: 20%;
font-style: italic;
text-align: center;
color: brown;
position: absolute;
font-weight: bolder;
background-color: #e1f5fe;
border-radius: 10px;
Expand Down
12 changes: 11 additions & 1 deletion Frontend/HTML/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</head>
<body>
<nav class="navbar">
<div id="notify">Notification alert</div>
<span> <div id="notify">Notification alert</div></span>
<div id="navmid">
<div id="topnavmid">
<div class="logo">
Expand Down Expand Up @@ -210,5 +210,15 @@ <h1>Save time, save money!</h1>

<input type="submit" name="Login" id="" />
</form> -->
<script type="text/javascript">
function preback() {
window.history.forward();
}
setTimeout("preback()", 0);
window.onload = function () {
null;
};
</script>
</html>

<script src="/JavaScript/admin.js"></script>
13 changes: 11 additions & 2 deletions Frontend/HTML/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</head>
<body>
<nav class="navbar">
<div id="notify">Notification alert</div>
<span><div id="notify">Notification alert</div></span>
<div id="navmid">
<div id="topnavmid">
<div class="logo">
Expand Down Expand Up @@ -115,7 +115,7 @@ <h3 onclick="canclePayment()">Cancle payment</h3>
<footer>
<div class="bottom1">
<div class="popup" id="pop">
<img src="404-tick.png" alt="thanks" />
<img src="/404-tick.png" alt="thanks" />
<h2>Thanks</h2>
<h3>We will reach to you soon!</h3>
<button id="close" onclick="closepopup()">Close</button>
Expand Down Expand Up @@ -193,5 +193,14 @@ <h1>Save time, save money!</h1>
</div>
</footer>
</body>
<script type="text/javascript">
function preback() {
window.history.forward();
}
setTimeout("preback()", 0);
window.onload = function () {
null;
};
</script>
</html>
<script src="/JavaScript/user.js"></script>
Loading