Changeset 27adfc8 for src/main


Ignore:
Timestamp:
02/04/23 18:48:07 (23 months ago)
Author:
milamihajlovska <mila.mihajlovska01@…>
Branches:
master
Children:
6032d44
Parents:
adf250d
Message:

register method

Location:
src/main/java/com/example/moviezone
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/model/Customer.java

    radf250d r27adfc8  
    2525    Integer points;
    2626
     27//    public Customer(String password, String first_name, String last_name, String address, String contact_number, String username) {
     28//        super(password, first_name, last_name, address, contact_number, username);
     29//    }
     30
    2731    @Override
    2832    public Collection<? extends GrantedAuthority> getAuthorities() {
    29         return Collections.singletonList(Role.ROLE_ADMIN);
     33        return Collections.singletonList(Role.ROLE_USER);
    3034    }
    3135
  • src/main/java/com/example/moviezone/model/User.java

    radf250d r27adfc8  
    4545    }
    4646
     47    public User(String password, String first_name, String last_name, String address, String contact_number, String username) {
     48        this.password = password;
     49        this.first_name = first_name;
     50        this.last_name = last_name;
     51        this.address = address;
     52        this.contact_number = contact_number;
     53        this.username = username;
     54        this.date_created=LocalDate.now();
     55    }
     56
    4757    public User() {
    4858
  • src/main/java/com/example/moviezone/model/Worker.java

    radf250d r27adfc8  
    77import org.springframework.security.core.GrantedAuthority;
    88
     9import java.time.LocalDate;
    910import java.util.Collection;
    1011import java.util.Collections;
     
    2627    @JoinColumn(name = "id_cinema")
    2728    Cinema cinema;
     29
     30//    public Worker(String password, String first_name, String last_name, String address, String contact_number, String username) {
     31//        super(password, first_name, last_name, address, contact_number, username);
     32//    }
     33
    2834    @Override
    2935    public Collection<? extends GrantedAuthority> getAuthorities() {
  • src/main/java/com/example/moviezone/service/Impl/UserServiceImpl.java

    radf250d r27adfc8  
    11package com.example.moviezone.service.Impl;
    22
     3import com.example.moviezone.model.Customer;
    34import com.example.moviezone.model.User;
     5import com.example.moviezone.model.Worker;
    46import com.example.moviezone.model.exceptions.UserNotFoundException;
    57import com.example.moviezone.repository.UserRepository;
    68import com.example.moviezone.service.UserService;
     9import org.springframework.security.crypto.password.PasswordEncoder;
    710import org.springframework.stereotype.Service;
    811
     
    1316
    1417    private final UserRepository userRepository;
     18    private final PasswordEncoder passwordEncoder;
    1519
    16     public UserServiceImpl(UserRepository userRepository) {
     20    public UserServiceImpl(UserRepository userRepository, PasswordEncoder passwordEncoder) {
    1721        this.userRepository = userRepository;
     22        this.passwordEncoder = passwordEncoder;
    1823    }
    1924
     
    3338    }
    3439
     40//    @Override
     41//    public User register(String first_name, String last_name, String username, String email, String number, String password, String role) {
     42//        if(role.equals("worker"))
     43//        {
     44//            return userRepository.save(new Worker(passwordEncoder.encode(password),first_name,last_name,username,email,number));
     45//        }
     46//        else if (role.equals("user"))
     47//            return userRepository.save(new Customer(passwordEncoder.encode(password),first_name,last_name,username,email,number));
     48//    }
     49
    3550
    3651}
  • src/main/java/com/example/moviezone/service/UserService.java

    radf250d r27adfc8  
    99    User findById(Integer user_id);
    1010    User findByUsername(String username);
     11
     12//    User register(String first_name, String last_name,String username, String email, String number, String password, String role);
     13
    1114}
Note: See TracChangeset for help on using the changeset viewer.