Index: phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/ConfirmationTokenService.java
===================================================================
--- phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/ConfirmationTokenService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
+++ phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/ConfirmationTokenService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
@@ -0,0 +1,28 @@
+package finki.it.phoneluxbackend.services;
+
+import finki.it.phoneluxbackend.repositories.ConfirmationTokenRepository;
+import finki.it.phoneluxbackend.entities.ConfirmationToken;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.Optional;
+
+@Service
+@AllArgsConstructor
+public class ConfirmationTokenService {
+    private final ConfirmationTokenRepository confirmationTokenRepository;
+
+    public void saveConfirmationToken(ConfirmationToken token) {
+        confirmationTokenRepository.save(token);
+    }
+
+    public Optional<ConfirmationToken> getToken(String token) {
+        return confirmationTokenRepository.findByToken(token);
+    }
+
+    public int setConfirmedAt(String token) {
+        return confirmationTokenRepository.updateConfirmedAt(
+                token, LocalDateTime.now());
+    }
+}
Index: phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/EmailService.java
===================================================================
--- phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/EmailService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
+++ phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/EmailService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
@@ -0,0 +1,40 @@
+package finki.it.phoneluxbackend.services;
+
+import finki.it.phoneluxbackend.security.email.EmailSender;
+import lombok.AllArgsConstructor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.MimeMessageHelper;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+@Service
+@AllArgsConstructor
+public class EmailService implements EmailSender {
+
+    private final JavaMailSender mailSender;
+    private final static Logger LOGGER = LoggerFactory.getLogger(EmailService.class);
+
+
+
+    @Override
+    @Async
+    public void send(String to, String email) {
+        try{
+            MimeMessage mimeMessage = mailSender.createMimeMessage();
+            MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,"utf-8");
+            helper.setText(email,true);
+            helper.setTo(to);
+            helper.setSubject("Confirm your email - Phonelux");
+            helper.setFrom("phonelux_official@gmail.com");
+            mailSender.send(mimeMessage);
+        } catch (MessagingException e){
+            LOGGER.error("Failed to send email ", e);
+            throw new IllegalStateException("Failed to send email");
+        }
+    }
+}
Index: phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/PhoneOfferService.java
===================================================================
--- phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/PhoneOfferService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
+++ phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/PhoneOfferService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
@@ -0,0 +1,28 @@
+package finki.it.phoneluxbackend.services;
+
+import finki.it.phoneluxbackend.entities.PhoneOffer;
+import finki.it.phoneluxbackend.repositories.PhoneOfferRepository;
+import finki.it.phoneluxbackend.repositories.PhoneRepository;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class PhoneOfferService {
+    private final PhoneOfferRepository phoneOfferRepository;
+    private final PhoneRepository phoneRepository;
+
+    public PhoneOfferService(PhoneOfferRepository phoneOfferRepository, PhoneRepository phoneRepository) {
+        this.phoneOfferRepository = phoneOfferRepository;
+        this.phoneRepository = phoneRepository;
+    }
+
+    public List<PhoneOffer> getPhoneOffersForPhone(Long phoneId) {
+        boolean exists = phoneRepository.existsById(phoneId);
+        if(!exists)
+            throw new IllegalStateException("Phone with id "+phoneId+" does not exist");
+
+        return phoneRepository.findById(phoneId).get().getPhoneOffers();
+    }
+}
Index: phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/PhoneService.java
===================================================================
--- phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/PhoneService.java	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/PhoneService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
@@ -21,10 +21,3 @@
     }
 
-    public List<PhoneOffer> getOffersForPhone(Long phoneId) {
-        boolean exists = phoneRepository.existsById(phoneId);
-        if(!exists)
-            throw new IllegalStateException("Phone with id "+phoneId+" does not exist");
-
-        return phoneRepository.findById(phoneId).get().getPhoneOffers();
-    }
 }
Index: phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/RegistrationService.java
===================================================================
--- phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/RegistrationService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
+++ phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/RegistrationService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
@@ -0,0 +1,134 @@
+package finki.it.phoneluxbackend.services;
+
+import finki.it.phoneluxbackend.data.RegistrationRequest;
+import finki.it.phoneluxbackend.data.UserRole;
+import finki.it.phoneluxbackend.entities.ConfirmationToken;
+import finki.it.phoneluxbackend.entities.User;
+import finki.it.phoneluxbackend.security.email.EmailSender;
+import finki.it.phoneluxbackend.security.email.EmailValidator;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+
+@Service
+@AllArgsConstructor
+public class RegistrationService {
+    private final UserService userService;
+    private final EmailValidator emailValidator;
+    private final ConfirmationTokenService confirmationTokenService;
+    private final EmailSender emailSender;
+
+
+    public String register(RegistrationRequest request) {
+        boolean isValidEmail = emailValidator.test(request.getEmail());
+
+        // validacija za mejl na frontend ?
+        if (!isValidEmail)
+            throw new IllegalStateException("Email"+request.getEmail()+" not valid!");
+
+        String token = userService.signUpUser(
+                new User(request.getFirstName(),
+                        request.getLastName(),
+                        request.getEmail(),
+                        request.getPassword(),
+                        UserRole.USER));
+
+        String link = "http://localhost:8080/registration/confirm?token="+token;
+        emailSender.send(request.getEmail(), buildEmail(request.getFirstName(),link));
+        return token;
+    }
+
+    private String buildEmail(String name, String link) {
+        return "<div style=\"font-family:Helvetica,Arial,sans-serif;font-size:16px;margin:0;color:#0b0c0c\">\n" +
+                "\n" +
+                "<span style=\"display:none;font-size:1px;color:#fff;max-height:0\"></span>\n" +
+                "\n" +
+                "  <table role=\"presentation\" width=\"100%\" style=\"border-collapse:collapse;min-width:100%;width:100%!important\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n" +
+                "    <tbody><tr>\n" +
+                "      <td width=\"100%\" height=\"53\" bgcolor=\"#0b0c0c\">\n" +
+                "        \n" +
+                "        <table role=\"presentation\" width=\"100%\" style=\"border-collapse:collapse;max-width:580px\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\">\n" +
+                "          <tbody><tr>\n" +
+                "            <td width=\"70\" bgcolor=\"#0b0c0c\" valign=\"middle\">\n" +
+                "                <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse\">\n" +
+                "                  <tbody><tr>\n" +
+                "                    <td style=\"padding-left:10px\">\n" +
+                "                  \n" +
+                "                    </td>\n" +
+                "                    <td style=\"font-size:28px;line-height:1.315789474;Margin-top:4px;padding-left:10px\">\n" +
+                "                      <span style=\"font-family:Helvetica,Arial,sans-serif;font-weight:700;color:#ffffff;text-decoration:none;vertical-align:top;display:inline-block\">Confirm your email</span>\n" +
+                "                    </td>\n" +
+                "                  </tr>\n" +
+                "                </tbody></table>\n" +
+                "              </a>\n" +
+                "            </td>\n" +
+                "          </tr>\n" +
+                "        </tbody></table>\n" +
+                "        \n" +
+                "      </td>\n" +
+                "    </tr>\n" +
+                "  </tbody></table>\n" +
+                "  <table role=\"presentation\" class=\"m_-6186904992287805515content\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse;max-width:580px;width:100%!important\" width=\"100%\">\n" +
+                "    <tbody><tr>\n" +
+                "      <td width=\"10\" height=\"10\" valign=\"middle\"></td>\n" +
+                "      <td>\n" +
+                "        \n" +
+                "                <table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse\">\n" +
+                "                  <tbody><tr>\n" +
+                "                    <td bgcolor=\"#1D70B8\" width=\"100%\" height=\"10\"></td>\n" +
+                "                  </tr>\n" +
+                "                </tbody></table>\n" +
+                "        \n" +
+                "      </td>\n" +
+                "      <td width=\"10\" valign=\"middle\" height=\"10\"></td>\n" +
+                "    </tr>\n" +
+                "  </tbody></table>\n" +
+                "\n" +
+                "\n" +
+                "\n" +
+                "  <table role=\"presentation\" class=\"m_-6186904992287805515content\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse;max-width:580px;width:100%!important\" width=\"100%\">\n" +
+                "    <tbody><tr>\n" +
+                "      <td height=\"30\"><br></td>\n" +
+                "    </tr>\n" +
+                "    <tr>\n" +
+                "      <td width=\"10\" valign=\"middle\"><br></td>\n" +
+                "      <td style=\"font-family:Helvetica,Arial,sans-serif;font-size:19px;line-height:1.315789474;max-width:560px\">\n" +
+                "        \n" +
+                "            <p style=\"Margin:0 0 20px 0;font-size:19px;line-height:25px;color:#0b0c0c\">Hi " + name + ",</p><p style=\"Margin:0 0 20px 0;font-size:19px;line-height:25px;color:#0b0c0c\"> Thank you for registering. Please click on the below link to activate your account: </p><blockquote style=\"Margin:0 0 20px 0;border-left:10px solid #b1b4b6;padding:15px 0 0.1px 15px;font-size:19px;line-height:25px\"><p style=\"Margin:0 0 20px 0;font-size:19px;line-height:25px;color:#0b0c0c\"> <a href=\"" + link + "\">Activate Now</a> </p></blockquote>\n Link will expire in 15 minutes. <p>See you soon</p>" +
+                "        \n" +
+                "      </td>\n" +
+                "      <td width=\"10\" valign=\"middle\"><br></td>\n" +
+                "    </tr>\n" +
+                "    <tr>\n" +
+                "      <td height=\"30\"><br></td>\n" +
+                "    </tr>\n" +
+                "  </tbody></table><div class=\"yj6qo\"></div><div class=\"adL\">\n" +
+                "\n" +
+                "</div></div>";
+    }
+
+
+    @Transactional
+    public String confirmToken(String token) {
+        ConfirmationToken confirmationToken = confirmationTokenService.getToken(token)
+                .orElseThrow(() -> new IllegalStateException("Token not found!"));
+
+        if(confirmationToken.getConfirmedAt() != null)
+            throw new IllegalStateException("Email already confirmed!");
+
+        LocalDateTime expiresAt = confirmationToken.getExpiresAt();
+
+        if (expiresAt.isBefore(LocalDateTime.now())){
+            throw new IllegalStateException("Token expired");
+        }
+
+        confirmationTokenService.setConfirmedAt(token);
+        userService.enableUser(confirmationToken.getUser().getEmail());
+
+        return "Email confirmed";
+    }
+
+
+}
Index: phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/UserService.java
===================================================================
--- phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/UserService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
+++ phonelux-backend/src/main/java/finki/it/phoneluxbackend/services/UserService.java	(revision dfd5d87e3f5f69d6d595f8987195c739e3aa6466)
@@ -0,0 +1,59 @@
+package finki.it.phoneluxbackend.services;
+
+import finki.it.phoneluxbackend.entities.User;
+import finki.it.phoneluxbackend.repositories.UserRepository;
+import finki.it.phoneluxbackend.entities.ConfirmationToken;
+import lombok.AllArgsConstructor;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.UUID;
+
+@Service
+@AllArgsConstructor
+public class UserService implements UserDetailsService {
+    private final UserRepository userRepository;
+    private final BCryptPasswordEncoder bCryptPasswordEncoder;
+    private final ConfirmationTokenService confirmationTokenService;
+
+
+    @Override
+    public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
+        return userRepository.findByEmail(email)
+                .orElseThrow(() -> new UsernameNotFoundException("User with email "+email+" not found!"));
+    }
+
+    public String signUpUser(User user)
+    {
+       boolean userExists =  userRepository.findByEmail(user.getEmail()).isPresent();
+
+       if (userExists && user.getEnabled()){
+           throw new IllegalStateException("Email "+user.getEmail()+" already taken!");
+       }
+
+       String encodedPassword = bCryptPasswordEncoder.encode(user.getPassword());
+
+       user.setPassword(encodedPassword);
+
+        String token = UUID.randomUUID().toString();
+        ConfirmationToken confirmationToken = new ConfirmationToken(token,
+                LocalDateTime.now(),
+                LocalDateTime.now().plusMinutes(15),
+                user
+                );
+
+        confirmationTokenService.saveConfirmationToken(confirmationToken);
+
+        return token;
+    }
+
+    public int enableUser(String email) {
+        return userRepository.enableUser(email);
+    }
+
+
+}
