Index: sources/app/src/main/java/parkup/configs/CustomAuthenticationFilter.java
===================================================================
--- sources/app/src/main/java/parkup/configs/CustomAuthenticationFilter.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
+++ sources/app/src/main/java/parkup/configs/CustomAuthenticationFilter.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -0,0 +1,93 @@
+package parkup.configs;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import parkup.entities.Administrator;
+import parkup.entities.RegisteredUser;
+import parkup.entities.Worker;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+
+@CrossOrigin
+public class CustomAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
+    private final AuthenticationManager authenticationManager;
+
+    public CustomAuthenticationFilter(AuthenticationManager authenticationManager) {
+        this.authenticationManager = authenticationManager;
+    }
+
+    @Override
+    public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
+        String username = request.getParameter("username");
+        String password = request.getParameter("password");
+        UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
+        return authenticationManager.authenticate(authenticationToken);
+    }
+
+    @Override
+    protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authentication) throws IOException, ServletException {
+        Object principal = authentication.getPrincipal();
+        String className = principal.getClass().getName().split("\\.")[2];
+        String email=null;
+        Collection<? extends GrantedAuthority> roles= new ArrayList<>();
+        switch (className) {
+            case "RegisteredUser": {
+                RegisteredUser user = (RegisteredUser) authentication.getPrincipal();
+                email = user.getEmail();
+                roles = user.getAuthorities();
+                break;
+            }
+            case "Worker": {
+                Worker user = (Worker) authentication.getPrincipal();
+                email = user.getEmail();
+                roles = user.getAuthorities();
+                break;
+            }
+            case "Administrator": {
+                Administrator user = (Administrator) authentication.getPrincipal();
+                email = user.getEmail();
+                roles = user.getAuthorities();
+                break;
+            }
+        }
+        //TODO see if guest needs to go through authentication
+        Algorithm algorithm = Algorithm.HMAC256("secret".getBytes());
+        String access_token = JWT.create()
+                .withSubject(email)
+                .withExpiresAt(new Date(System.currentTimeMillis() + 60 * 60 * 1000))
+                .withIssuer(request.getRequestURL().toString())
+                .withClaim("roles", roles.stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList()))
+                .sign(algorithm);
+//        String refresh_token = JWT.create()
+//                .withSubject(user.getUsername())
+//                .withExpiresAt(new Date(System.currentTimeMillis() + 30 * 60 * 1000))
+//                .withIssuer(request.getRequestURL().toString())
+//                .sign(algorithm);
+        Map<String, String> tokens = new HashMap<>();
+        tokens.put("access_token", access_token);
+//        tokens.put("refresh_token", refresh_token);
+        response.setContentType(APPLICATION_JSON_VALUE);
+        new ObjectMapper().writeValue(response.getOutputStream(), tokens);
+    }
+}
Index: sources/app/src/main/java/parkup/configs/CustomAuthorizationFilter.java
===================================================================
--- sources/app/src/main/java/parkup/configs/CustomAuthorizationFilter.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
+++ sources/app/src/main/java/parkup/configs/CustomAuthorizationFilter.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -0,0 +1,68 @@
+package parkup.configs;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.interfaces.DecodedJWT;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.util.MimeTypeUtils;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import static java.util.Arrays.stream;
+import static org.springframework.http.HttpHeaders.AUTHORIZATION;
+import static org.springframework.http.HttpStatus.FORBIDDEN;
+
+
+@CrossOrigin
+public class CustomAuthorizationFilter extends OncePerRequestFilter {
+    @Override
+    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
+        if(request.getServletPath().equals("/api/login") || request.getServletPath().equals("/api/token/refresh")) {
+            filterChain.doFilter(request, response);
+        } else {
+            String authorizationHeader = request.getHeader(AUTHORIZATION);
+            if(authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) {
+                try {
+                    String token = authorizationHeader.substring("Bearer ".length());
+                    Algorithm algorithm = Algorithm.HMAC256("secret".getBytes());
+                    JWTVerifier verifier = JWT.require(algorithm).build();
+                    DecodedJWT decodedJWT = verifier.verify(token);
+                    String username = decodedJWT.getSubject();
+                    String[] roles = decodedJWT.getClaim("roles").asArray(String.class);
+                    Collection<SimpleGrantedAuthority> authorities = new ArrayList<>();
+                    stream(roles).forEach(role -> {
+                        authorities.add(new SimpleGrantedAuthority(role));
+                    });
+                    UsernamePasswordAuthenticationToken authenticationToken =
+                            new UsernamePasswordAuthenticationToken(username, null, authorities);
+                    SecurityContextHolder.getContext().setAuthentication(authenticationToken);
+                    filterChain.doFilter(request, response);
+                }catch (Exception exception) {
+                    response.setHeader("error", exception.getMessage());
+                    response.setStatus(FORBIDDEN.value());
+                    //response.sendError(FORBIDDEN.value());
+                    Map<String, String> error = new HashMap<>();
+                    error.put("error_message", exception.getMessage());
+                    response.setContentType(MimeTypeUtils.APPLICATION_JSON_VALUE);
+                    new ObjectMapper().writeValue(response.getOutputStream(), error);
+                }
+            } else {
+                filterChain.doFilter(request, response);
+            }
+        }
+    }
+}
Index: sources/app/src/main/java/parkup/configs/RegistrationServiceRP.java
===================================================================
--- sources/app/src/main/java/parkup/configs/RegistrationServiceRP.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/configs/RegistrationServiceRP.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -3,10 +3,11 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import parkup.configs.email.EmailSender;
+import parkup.configs.email.EmailService;
 import parkup.configs.email.EmailValidator;
+import parkup.configs.email.Mail;
 import parkup.configs.token.ConfirmationTokenRP;
 import parkup.configs.token.ConfirmationTokenService;
-import parkup.entities.RegistriranParkirac;
-import parkup.services.RegistriranParkiracService;
+import parkup.entities.RegisteredUser;
+import parkup.services.RegisteredUserService;
 
 import javax.transaction.Transactional;
@@ -15,19 +16,21 @@
 @Service
 public class RegistrationServiceRP {
-    private final RegistriranParkiracService registriranParkiracService;
+    private final RegisteredUserService registeredUserService;
     private final EmailValidator emailValidator;
     private final ConfirmationTokenService confirmationTokenService;
-    private final EmailSender emailSender;
+    private final EmailService emailService;
 
     @Autowired
-    public RegistrationServiceRP(RegistriranParkiracService registriranParkiracService, EmailValidator emailValidator,
-                                 ConfirmationTokenService confirmationTokenService, EmailSender emailSender) {
-        this.registriranParkiracService = registriranParkiracService;
+    public RegistrationServiceRP(RegisteredUserService registeredUserService, EmailValidator emailValidator,
+                                 ConfirmationTokenService confirmationTokenService, EmailService emailService) {
+        this.registeredUserService = registeredUserService;
         this.emailValidator = emailValidator;
         this.confirmationTokenService = confirmationTokenService;
-        this.emailSender = emailSender;
+        this.emailService = emailService;
     }
 
     public String register(RegistrationRequest request) {
+        if (request.getEmail() == null || request.getEmail().isEmpty())
+            throw new IllegalArgumentException("Missing email");
         boolean isValidEmail = emailValidator.
                 test(request.getEmail());
@@ -37,6 +40,6 @@
         }
 
-        String token = registriranParkiracService.signUpRegistriranParkirac(
-                new RegistriranParkirac(
+        String token = registeredUserService.signUpRegistriranParkirac(
+                new RegisteredUser(
                         request.getFirstName(),
                         request.getLastName(),
@@ -48,8 +51,10 @@
 
         String link = "http://localhost:8080/registriranParkirac/registration/confirm?token=" + token;
-        emailSender.send(
-                request.getEmail(),
-                buildEmail(request.getFirstName(), link));
-
+        Mail mail = new Mail();
+        mail.setMailTo(request.getEmail());
+        mail.setMailFrom("noreply_explore_buddy@gmail.com");
+        mail.setMailSubject("Account confirmation");
+        mail.setMailContent(buildEmail(request.getEmail(), link));
+        emailService.sendEmail(mail);
         return token;
     }
@@ -74,5 +79,5 @@
         confirmationTokenService.setConfirmedAtRP(token);
 
-        registriranParkiracService.enableRegistriranParkirac(confirmationTokenRP.getRegistriranParkirac().getEmail());
+        registeredUserService.enableRegistriranParkirac(confirmationTokenRP.getRegistriranParkirac().getEmail());
         return "confirmed";
     }
Index: sources/app/src/main/java/parkup/configs/RegistrationServiceW.java
===================================================================
--- sources/app/src/main/java/parkup/configs/RegistrationServiceW.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ 	(revision )
@@ -1,148 +1,0 @@
-//package parkup.configs;
-//
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.stereotype.Service;
-//import parkup.configs.email.EmailSender;
-//import parkup.configs.email.EmailValidator;
-//import parkup.configs.token.ConfirmationTokenW;
-//import parkup.configs.token.ConfirmationTokenService;
-//import parkup.entities.Vraboten;
-//import parkup.services.VrabotenService;
-//
-//import javax.transaction.Transactional;
-//import java.time.LocalDateTime;
-//
-//@Service
-//public class RegistrationServiceW {
-//    private final VrabotenService vrabotenService;
-//    private final EmailValidator emailValidator;
-//    private final ConfirmationTokenService confirmationTokenService;
-//    private final EmailSender emailSender;
-//
-//    @Autowired
-//    public RegistrationServiceW(VrabotenService vrabotenService, EmailValidator emailValidator,
-//                                 ConfirmationTokenService confirmationTokenService, EmailSender emailSender) {
-//        this.vrabotenService = vrabotenService;
-//        this.emailValidator = emailValidator;
-//        this.confirmationTokenService = confirmationTokenService;
-//        this.emailSender = emailSender;
-//    }
-//
-//    public String register(RegistrationRequest request) {
-//        boolean isValidEmail = emailValidator.
-//                test(request.getEmail());
-//
-//        if (!isValidEmail) {
-//            throw new IllegalStateException("email not valid");
-//        }
-//
-//        String token = vrabotenService.signUpVraboten(
-//                new Vraboten(
-//                        request.getFirstName(),
-//                        request.getLastName(),
-//                        request.getEmail(),
-//                        request.getPassword(),
-//                        request.getMobile()
-//                )
-//        );
-//
-//        String link = "http://localhost:8080/vraboten/registration/confirm?token=" + token;
-//        emailSender.send(
-//                request.getEmail(),
-//                buildEmail(request.getFirstName(), link));
-//
-//        return token;
-//    }
-//
-//    @Transactional
-//    public String confirmToken(String token) {
-//        ConfirmationTokenW confirmationTokenW = confirmationTokenService
-//                .getTokenW(token)
-//                .orElseThrow(() ->
-//                        new IllegalStateException("token not found"));
-//
-//        if (confirmationTokenW.getConfirmedAt() != null) {
-//            throw new IllegalStateException("email already confirmed");
-//        }
-//
-//        LocalDateTime expiredAt = confirmationTokenW.getExpiresAt();
-//
-//        if (expiredAt.isBefore(LocalDateTime.now())) {
-//            throw new IllegalStateException("token expired");
-//        }
-//
-//        confirmationTokenService.setConfirmedAtW(token);
-//
-//        vrabotenService.enableVraboten(confirmationTokenW.getRegistriranParkirac().getEmail());
-//        return "confirmed";
-//    }
-//
-//    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>";
-//    }
-//}
Index: sources/app/src/main/java/parkup/configs/email/EmailSender.java
===================================================================
--- sources/app/src/main/java/parkup/configs/email/EmailSender.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ 	(revision )
@@ -1,5 +1,0 @@
-package parkup.configs.email;
-
-public interface EmailSender {
-    void send(String to, String email);
-}
Index: sources/app/src/main/java/parkup/configs/email/EmailService.java
===================================================================
--- sources/app/src/main/java/parkup/configs/email/EmailService.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/configs/email/EmailService.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -1,41 +1,38 @@
 package parkup.configs.email;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 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.InternetAddress;
 import javax.mail.internet.MimeMessage;
+import java.io.UnsupportedEncodingException;
 
-@Service
-public class EmailService implements EmailSender{
+@Service("mailService")
+public class EmailService implements MailService {
 
-    private final static Logger LOGGER = LoggerFactory.getLogger(EmailService.class);
-    private final JavaMailSender mailSender;
+    @Autowired
+    JavaMailSender mailSender;
 
-    public EmailService(JavaMailSender mailSender) {
-        this.mailSender = mailSender;
+    public void sendEmail(Mail mail) {
+        MimeMessage mimeMessage = mailSender.createMimeMessage();
+
+        try {
+
+            MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true);
+
+            mimeMessageHelper.setSubject(mail.getMailSubject());
+            mimeMessageHelper.setFrom(new InternetAddress(mail.getMailFrom(), "parkUp.com"));
+            mimeMessageHelper.setTo(mail.getMailTo());
+            mimeMessageHelper.setText(mail.getMailContent(), true);
+
+            mailSender.send(mimeMessageHelper.getMimeMessage());
+
+        } catch (MessagingException | UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
     }
 
-    @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");
-            helper.setFrom("parkup@gmail.com");
-            mailSender.send(mimeMessage);
-        } catch (MessagingException e) {
-            LOGGER.error("failed to send email", e);
-            throw new IllegalStateException("failed to send email");
-        }
-    }
 }
-
Index: sources/app/src/main/java/parkup/configs/email/EmailValidator.java
===================================================================
--- sources/app/src/main/java/parkup/configs/email/EmailValidator.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/configs/email/EmailValidator.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -1,7 +1,9 @@
 package parkup.configs.email;
+
 
 import org.springframework.stereotype.Service;
 
 import java.util.function.Predicate;
+import java.util.regex.Pattern;
 
 @Service
@@ -9,6 +11,6 @@
     @Override
     public boolean test(String s) {
-        //todo
-        return true;
+        String regexPattern = "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$";
+        return Pattern.compile(regexPattern).matcher(s).matches();
     }
 }
Index: sources/app/src/main/java/parkup/configs/email/Mail.java
===================================================================
--- sources/app/src/main/java/parkup/configs/email/Mail.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
+++ sources/app/src/main/java/parkup/configs/email/Mail.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -0,0 +1,96 @@
+package parkup.configs.email;
+
+import java.util.Date;
+import java.util.List;
+
+public class Mail {
+
+    private String mailFrom;
+
+    private String mailTo;
+
+    private String mailCc;
+
+    private String mailBcc;
+
+    private String mailSubject;
+
+    private String mailContent;
+
+    private String contentType;
+
+    private List < Object > attachments;
+
+    public Mail() {
+        contentType = "text/plain";
+    }
+
+    public String getContentType() {
+        return contentType;
+    }
+
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
+
+    public String getMailBcc() {
+        return mailBcc;
+    }
+
+    public void setMailBcc(String mailBcc) {
+        this.mailBcc = mailBcc;
+    }
+
+    public String getMailCc() {
+        return mailCc;
+    }
+
+    public void setMailCc(String mailCc) {
+        this.mailCc = mailCc;
+    }
+
+    public String getMailFrom() {
+        return mailFrom;
+    }
+
+    public void setMailFrom(String mailFrom) {
+        this.mailFrom = mailFrom;
+    }
+
+    public String getMailSubject() {
+        return mailSubject;
+    }
+
+    public void setMailSubject(String mailSubject) {
+        this.mailSubject = mailSubject;
+    }
+
+    public String getMailTo() {
+        return mailTo;
+    }
+
+    public void setMailTo(String mailTo) {
+        this.mailTo = mailTo;
+    }
+
+    public Date getMailSendDate() {
+        return new Date();
+    }
+
+    public String getMailContent() {
+        return mailContent;
+    }
+
+    public void setMailContent(String mailContent) {
+        this.mailContent = mailContent;
+    }
+
+    public List < Object > getAttachments() {
+        return attachments;
+    }
+
+    public void setAttachments(List < Object > attachments) {
+        this.attachments = attachments;
+    }
+
+}
Index: sources/app/src/main/java/parkup/configs/email/MailConfig.java
===================================================================
--- sources/app/src/main/java/parkup/configs/email/MailConfig.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
+++ sources/app/src/main/java/parkup/configs/email/MailConfig.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -0,0 +1,36 @@
+package parkup.configs.email;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.JavaMailSenderImpl;
+
+import java.util.Properties;
+
+@Configuration
+public class MailConfig {
+
+    @Autowired
+    private Environment env;
+
+    @Bean
+    public JavaMailSender getMailSender() {
+        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
+
+        mailSender.setHost(env.getProperty("spring.mail.host"));
+        mailSender.setPort(Integer.valueOf(env.getProperty("spring.mail.port")));
+        mailSender.setUsername(env.getProperty("spring.mail.username"));
+        mailSender.setPassword(env.getProperty("spring.mail.password"));
+
+        Properties javaMailProperties = new Properties();
+        javaMailProperties.put("mail.smtp.starttls.enable", "true");
+        javaMailProperties.put("mail.smtp.auth", "true");
+        javaMailProperties.put("mail.transport.protocol", "smtp");
+        javaMailProperties.put("mail.debug", "true");
+
+        mailSender.setJavaMailProperties(javaMailProperties);
+        return mailSender;
+    }
+}
Index: sources/app/src/main/java/parkup/configs/email/MailService.java
===================================================================
--- sources/app/src/main/java/parkup/configs/email/MailService.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
+++ sources/app/src/main/java/parkup/configs/email/MailService.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -0,0 +1,5 @@
+package parkup.configs.email;
+
+public interface MailService {
+        public void sendEmail(Mail mail);
+}
Index: sources/app/src/main/java/parkup/configs/token/ConfirmationTokenRP.java
===================================================================
--- sources/app/src/main/java/parkup/configs/token/ConfirmationTokenRP.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/configs/token/ConfirmationTokenRP.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -1,5 +1,5 @@
 package parkup.configs.token;
 
-import parkup.entities.RegistriranParkirac;
+import parkup.entities.RegisteredUser;
 
 import javax.persistence.*;
@@ -37,21 +37,21 @@
     @JoinColumn(nullable = false, name = "registriranParkirac_id")
     //many confirmation tokens to one registriranParkirac
-    private RegistriranParkirac registriranParkirac;
+    private RegisteredUser registeredUser;
 
     public ConfirmationTokenRP() {}
 
-    public ConfirmationTokenRP(int id, String token, LocalDateTime createdAt, LocalDateTime expiresAt, RegistriranParkirac registriranParkirac) {
+    public ConfirmationTokenRP(int id, String token, LocalDateTime createdAt, LocalDateTime expiresAt, RegisteredUser registeredUser) {
         this.id = id;
         this.token = token;
         this.createdAt = createdAt;
         this.expiresAt = expiresAt;
-        this.registriranParkirac = registriranParkirac;
+        this.registeredUser = registeredUser;
     }
 
-    public ConfirmationTokenRP(String token, LocalDateTime createdAt, LocalDateTime expiresAt, RegistriranParkirac registriranParkirac) {
+    public ConfirmationTokenRP(String token, LocalDateTime createdAt, LocalDateTime expiresAt, RegisteredUser registeredUser) {
         this.token = token;
         this.createdAt = createdAt;
         this.expiresAt = expiresAt;
-        this.registriranParkirac = registriranParkirac;
+        this.registeredUser = registeredUser;
     }
 
@@ -96,10 +96,10 @@
     }
 
-    public RegistriranParkirac getRegistriranParkirac() {
-        return registriranParkirac;
+    public RegisteredUser getRegistriranParkirac() {
+        return registeredUser;
     }
 
-    public void setRegistriranParkirac(RegistriranParkirac registriranParkirac) {
-        this.registriranParkirac = registriranParkirac;
+    public void setRegistriranParkirac(RegisteredUser registeredUser) {
+        this.registeredUser = registeredUser;
     }
 }
Index: sources/app/src/main/java/parkup/configs/token/ConfirmationTokenRepositoryRP.java
===================================================================
--- sources/app/src/main/java/parkup/configs/token/ConfirmationTokenRepositoryRP.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/configs/token/ConfirmationTokenRepositoryRP.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -15,5 +15,5 @@
     Optional<ConfirmationTokenRP> findByToken(String token);
 
-    void deleteByRegistriranParkirac_RegParkId(int regParkId);
+    void deleteByRegisteredUser_RegParkId(int regParkId);
 
     @Transactional
Index: sources/app/src/main/java/parkup/configs/token/ConfirmationTokenRepositoryW.java
===================================================================
--- sources/app/src/main/java/parkup/configs/token/ConfirmationTokenRepositoryW.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ 	(revision )
@@ -1,25 +1,0 @@
-package parkup.configs.token;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Modifying;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.stereotype.Repository;
-
-import javax.transaction.Transactional;
-import java.time.LocalDateTime;
-import java.util.Optional;
-
-@Repository
-public interface ConfirmationTokenRepositoryW extends JpaRepository<ConfirmationTokenW,Integer> {
-
-    Optional<ConfirmationTokenW> findByToken(String token);
-
-    void deleteByVraboten_VrabotenId(int vraboten_id);
-
-    @Transactional
-    @Modifying
-    @Query("UPDATE ConfirmationTokenW c " +
-            "SET c.confirmedAt = ?2 " +
-            "WHERE c.token = ?1")
-    int updateConfirmedAt(String token, LocalDateTime confirmedAt);
-}
Index: sources/app/src/main/java/parkup/configs/token/ConfirmationTokenService.java
===================================================================
--- sources/app/src/main/java/parkup/configs/token/ConfirmationTokenService.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/configs/token/ConfirmationTokenService.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -10,10 +10,8 @@
 
     private final ConfirmationTokenRepositoryRP confirmationTokenRepositoryRP;
-    private final ConfirmationTokenRepositoryW confirmationTokenRepositoryW;
 
 
-    public ConfirmationTokenService(ConfirmationTokenRepositoryRP confirmationTokenRepositoryRP, ConfirmationTokenRepositoryW confirmationTokenRepositoryW, parkup.configs.token.ConfirmationTokenRepositoryW confirmationTokenRepositoryW1) {
+    public ConfirmationTokenService(ConfirmationTokenRepositoryRP confirmationTokenRepositoryRP) {
         this.confirmationTokenRepositoryRP = confirmationTokenRepositoryRP;
-        this.confirmationTokenRepositoryW = confirmationTokenRepositoryW1;
     }
     public void saveConfirmationTokenRP(ConfirmationTokenRP token){
@@ -21,20 +19,11 @@
     }
 
-    public void saveConfirmationTokenW(ConfirmationTokenW token){
-        confirmationTokenRepositoryW.save(token);}
 
     public Optional<ConfirmationTokenRP> getTokenRP(String token) {
         return confirmationTokenRepositoryRP.findByToken(token);
     }
-    public Optional<ConfirmationTokenW> getTokenW(String token){
-        return confirmationTokenRepositoryW.findByToken(token);
-    }
 
-    public void deleteByVraboten_VrabotenId(int vraboten_id){
-        confirmationTokenRepositoryW.deleteByVraboten_VrabotenId(vraboten_id);
-    }
-
-    public void deleteByRegistriranParkirac_RegParkId(int regParkId){
-        confirmationTokenRepositoryRP.deleteByRegistriranParkirac_RegParkId(regParkId);
+    public void deleteByRegisteredUser_RegParkId(int regParkId){
+        confirmationTokenRepositoryRP.deleteByRegisteredUser_RegParkId(regParkId);
     }
 
@@ -42,6 +31,3 @@
         return confirmationTokenRepositoryRP.updateConfirmedAt(token, LocalDateTime.now());
     }
-    public int setConfirmedAtW(String token){
-        return confirmationTokenRepositoryW.updateConfirmedAt(token,LocalDateTime.now());
-    }
 }
Index: sources/app/src/main/java/parkup/configs/token/ConfirmationTokenW.java
===================================================================
--- sources/app/src/main/java/parkup/configs/token/ConfirmationTokenW.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ 	(revision )
@@ -1,105 +1,0 @@
-package parkup.configs.token;
-
-import parkup.entities.Vraboten;
-
-import javax.persistence.*;
-import java.time.LocalDateTime;
-
-@Entity
-public class ConfirmationTokenW {
-
-    @Id
-    @Column(name = "confirmation_token_id")
-    @SequenceGenerator(
-            name="confirmation_token_sequence_generator_W",
-            sequenceName = "confirmation_token_sequence_W",
-            allocationSize = 1,
-            initialValue = 1200
-    )
-    @GeneratedValue(    //za postgres treba sequence da se namesti i ime na generator mi ga davamo kako od gore sto e
-            strategy = GenerationType.SEQUENCE,
-            generator = "confirmation_token_sequence_generator_W"
-    )
-    private int id;
-
-    @Column(nullable = false)
-    private String token;
-
-    @Column(nullable = false)
-    private LocalDateTime createdAt;
-
-    @Column(nullable = false)
-    private LocalDateTime expiresAt;
-
-    private LocalDateTime confirmedAt;
-
-    @ManyToOne(cascade = {CascadeType.ALL})
-    @JoinColumn(nullable = false, name = "vraboten_id")
-    //many confirmation tokens to one registriranParkirac
-    private Vraboten vraboten;
-
-    public ConfirmationTokenW() {}
-
-    public ConfirmationTokenW(int id, String token, LocalDateTime createdAt, LocalDateTime expiresAt, Vraboten vraboten) {
-        this.id = id;
-        this.token = token;
-        this.createdAt = createdAt;
-        this.expiresAt = expiresAt;
-        this.vraboten = vraboten;
-    }
-
-    public ConfirmationTokenW(String token, LocalDateTime createdAt, LocalDateTime expiresAt, Vraboten vraboten) {
-        this.token = token;
-        this.createdAt = createdAt;
-        this.expiresAt = expiresAt;
-        this.vraboten = vraboten;
-    }
-
-    public int getId() {
-        return id;
-    }
-
-    public void setId(int id) {
-        this.id = id;
-    }
-
-    public String getToken() {
-        return token;
-    }
-
-    public void setToken(String token) {
-        this.token = token;
-    }
-
-    public LocalDateTime getCreatedAt() {
-        return createdAt;
-    }
-
-    public void setCreatedAt(LocalDateTime createdAt) {
-        this.createdAt = createdAt;
-    }
-
-    public LocalDateTime getExpiresAt() {
-        return expiresAt;
-    }
-
-    public void setExpiresAt(LocalDateTime expiresAt) {
-        this.expiresAt = expiresAt;
-    }
-
-    public LocalDateTime getConfirmedAt() {
-        return confirmedAt;
-    }
-
-    public void setConfirmedAt(LocalDateTime confirmedAt) {
-        this.confirmedAt = confirmedAt;
-    }
-
-    public Vraboten getRegistriranParkirac() {
-        return vraboten;
-    }
-
-    public void setRegistriranParkirac(Vraboten vraboten) {
-        this.vraboten = vraboten;
-    }
-}
Index: sources/app/src/main/java/parkup/configs/webConfigs/WebSecurityConfig.java
===================================================================
--- sources/app/src/main/java/parkup/configs/webConfigs/WebSecurityConfig.java	(revision 9ff45d65e1d0058eb0c79395ba62a726630c2daa)
+++ sources/app/src/main/java/parkup/configs/webConfigs/WebSecurityConfig.java	(revision 98f448a5217d1b04c85405d87889e64c1b6debb3)
@@ -3,5 +3,5 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
+import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@@ -9,52 +9,58 @@
 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import parkup.services.RegistriranParkiracService;
-import parkup.services.VrabotenService;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+import org.springframework.web.cors.CorsConfiguration;
+import parkup.configs.CustomAuthenticationFilter;
+import parkup.configs.CustomAuthorizationFilter;
+import parkup.services.AdministratorService;
+import parkup.services.RegisteredUserService;
+import parkup.services.WorkerService;
+
+import static org.springframework.security.config.http.SessionCreationPolicy.STATELESS;
 
 @EnableWebSecurity
 @Configuration
 public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
-        private final VrabotenService vrabotenService;
+        private final WorkerService workerService;
         private final BCryptPasswordEncoder bCryptPasswordEncoder;
-        private final RegistriranParkiracService registriranParkiracService;
+        private final RegisteredUserService registeredUserService;
+        private final AdministratorService administratorService;
 
-        public WebSecurityConfig(VrabotenService vrabotenService, BCryptPasswordEncoder bCryptPasswordEncoder, RegistriranParkiracService registriranParkiracService) {
-            this.vrabotenService = vrabotenService;
+        public WebSecurityConfig(WorkerService workerService, BCryptPasswordEncoder bCryptPasswordEncoder, RegisteredUserService registeredUserService, AdministratorService administratorService) {
+            this.workerService = workerService;
             this.bCryptPasswordEncoder = bCryptPasswordEncoder;
-            this.registriranParkiracService = registriranParkiracService;
+            this.registeredUserService = registeredUserService;
+            this.administratorService = administratorService;
+        }
+
+        @Override
+        protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+            auth.userDetailsService(registeredUserService).passwordEncoder(bCryptPasswordEncoder);
+            auth.userDetailsService(workerService).passwordEncoder(bCryptPasswordEncoder);
+            auth.userDetailsService(administratorService).passwordEncoder(bCryptPasswordEncoder);
         }
 
         @Override
         protected void configure(HttpSecurity http) throws Exception {
-            http
-                    .csrf().disable()
-                    .authorizeRequests()
-                        .antMatchers("/registriranParkirac/registration/**")
-                        .permitAll()
-                    .anyRequest()
-                    .authenticated().and().formLogin();//ruta na viktor
-        }
-
-        @Override
-        protected void configure(AuthenticationManagerBuilder auth) throws Exception {
-            auth.authenticationProvider(daoAuthenticationProviderW());
-            auth.authenticationProvider(daoAuthenticationProviderRP());
+            CustomAuthenticationFilter customAuthenticationFilter = new CustomAuthenticationFilter(authenticationManagerBean());
+            customAuthenticationFilter.setFilterProcessesUrl("/api/login");
+            http.csrf().disable();
+            http.cors().configurationSource(request -> new CorsConfiguration().applyPermitDefaultValues());
+            http.sessionManagement().sessionCreationPolicy(STATELESS);
+            http.authorizeRequests().antMatchers("/**").permitAll();
+//            http.authorizeRequests().antMatchers("/user/registration/**", "/home/markers","/home/getLocation/**","/api/login/**","/home").permitAll();
+//            http.authorizeRequests().antMatchers( "/user/setFavourite/**","user/favourites").hasAuthority("ROLE_USER");
+//            http.authorizeRequests().antMatchers( "/home/**").hasAuthority("ROLE_ADMIN");
+//            http.authorizeRequests().anyRequest().authenticated();
+            http.addFilter(customAuthenticationFilter);
+            http.addFilterBefore(new CustomAuthorizationFilter(), UsernamePasswordAuthenticationFilter.class);
         }
 
         @Bean
-        public DaoAuthenticationProvider daoAuthenticationProviderW() {
-            DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
-            provider.setPasswordEncoder(bCryptPasswordEncoder);
-            provider.setUserDetailsService(vrabotenService);
-            return provider;
+        @Override
+        public AuthenticationManager authenticationManagerBean() throws Exception {
+            return super.authenticationManagerBean();
         }
 
-        @Bean
-        public DaoAuthenticationProvider daoAuthenticationProviderRP(){
-            DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
-            provider.setPasswordEncoder(bCryptPasswordEncoder);
-            provider.setUserDetailsService(registriranParkiracService);
-            return provider;
-        }
 
     }
