Vendor Dashboard and Store dashboard added

This commit is contained in:
Sidharth Prabhu
2026-04-09 15:35:42 +05:30
parent dd3e811cdf
commit 4dc0b37bad
9 changed files with 68 additions and 57 deletions

0
backend/mvnw vendored Normal file → Executable file
View File

View File

@@ -4,6 +4,7 @@ import com.rit.canteen.sales.model.SystemUser;
import com.rit.canteen.sales.repository.SystemUserRepository;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
@@ -19,6 +20,12 @@ public class SystemUserService {
@Autowired
private BCryptPasswordEncoder passwordEncoder;
@Value("${app.master.username:admin}")
private String masterUsername;
@Value("${app.master.password:admin}")
private String masterPassword;
@PostConstruct
public void init() {
// Handle migration from old credentials if they exist
@@ -28,31 +35,31 @@ public class SystemUserService {
repository.delete(oldUser);
System.out.println(">>> REMOVED OBSOLETE MASTER USER: admin@ritcanteen.com");
} else {
oldUser.setEmail("admin");
oldUser.setPassword(passwordEncoder.encode("admin"));
oldUser.setEmail(masterUsername);
oldUser.setPassword(passwordEncoder.encode(masterPassword));
repository.save(oldUser);
System.out.println(">>> MIGRATED MASTER USER: admin / admin");
}
});
// Ensure 'admin' user exists and has the correct password
Optional<SystemUser> adminUser = repository.findByEmail("admin");
Optional<SystemUser> adminUser = repository.findByEmail(masterUsername);
if (adminUser.isPresent()) {
SystemUser admin = adminUser.get();
admin.setPassword(passwordEncoder.encode("admin"));
admin.setPassword(passwordEncoder.encode(masterPassword));
admin.setRole("MASTER");
repository.save(admin);
System.out.println(">>> UPDATED MASTER USER PASSWORD: admin / admin");
System.out.println(">>> UPDATED MASTER USER PASSWORD: " + masterUsername + " / " + masterPassword);
} else {
SystemUser master = new SystemUser();
master.setName("Admin Master");
master.setEmail("admin");
master.setPassword(passwordEncoder.encode("admin"));
master.setEmail(masterUsername);
master.setPassword(passwordEncoder.encode(masterPassword));
master.setRole("MASTER");
master.setPermissions(List.of("dashboard", "sale", "customers", "purchases", "inventory", "expense", "reports", "stores", "table", "wallet", "promotions", "feedback"));
master.setViewOnly(false);
repository.save(master);
System.out.println(">>> SEEDED MASTER USER: admin / admin");
System.out.println(">>> SEEDED MASTER USER: " + masterUsername + " / " + masterPassword);
}
}

View File

@@ -1,11 +1,15 @@
spring.application.name=backend
server.address=0.0.0.0
spring.datasource.url=jdbc:postgresql://localhost:5432/canteen_automation
spring.datasource.url=jdbc:postgresql://localhost:5432/positeasy
spring.datasource.username=postgres
spring.datasource.password=Abiram@07
spring.datasource.password=sidharth
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
# Master Account Credentials
app.master.username=admin
app.master.password=admin