source: src/main/java/com/example/salonbella/startup/CommandLineAppStartupRunner.java

Last change on this file was 74af394, checked in by makyjovanovsky <mjovanovski04@…>, 17 months ago

login/register with mail confirmation

  • Property mode set to 100644
File size: 1.7 KB
Line 
1package com.example.salonbella.startup;
2
3import com.example.salonbella.entity.UserEntity;
4import com.example.salonbella.service.UserService;
5import org.springframework.beans.factory.annotation.Autowired;
6import org.springframework.boot.CommandLineRunner;
7import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
8import org.springframework.security.crypto.password.PasswordEncoder;
9import org.springframework.stereotype.Component;
10
11@Component
12public class CommandLineAppStartupRunner implements CommandLineRunner {
13
14 private final UserService userService;
15
16 @Autowired
17 public CommandLineAppStartupRunner(UserService userService) {
18 this.userService = userService;
19 }
20
21 @Override
22 public void run(String... args) throws Exception {
23 PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(10);
24 UserEntity userEntity = new UserEntity();
25 userEntity.setName("Mladen");
26 userEntity.setSurname("Jovanovski");
27 userEntity.setEmail("mjovanovski04@gmail.com");
28 userEntity.setPassword(passwordEncoder.encode("admin"));
29 userEntity.setUsername("admin");
30 userEntity.setRole("ADMIN");
31 userEntity.setValid(true);
32 userEntity.setNumber("072312134");
33 userService.registerAdmin(userEntity);
34
35 UserEntity userEntity2 = new UserEntity();
36 userEntity2.setName("Mladen");
37 userEntity2.setSurname("Jovanovski");
38 userEntity2.setEmail("m@gmail.com");
39 userEntity2.setPassword(passwordEncoder.encode("maky"));
40 userEntity2.setUsername("maky");
41 userEntity2.setRole("USER");
42 userEntity2.setValid(true);
43 userEntity2.setNumber("072312134");
44 userService.registerAdmin(userEntity2);
45
46
47 }
48}
Note: See TracBrowser for help on using the repository browser.