Index: springapp/src/main/java/mk/profesori/springapp/Controller/PublicController.java
===================================================================
--- springapp/src/main/java/mk/profesori/springapp/Controller/PublicController.java	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ springapp/src/main/java/mk/profesori/springapp/Controller/PublicController.java	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -1,5 +1,7 @@
 package mk.profesori.springapp.Controller;
 
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
 
@@ -21,5 +23,5 @@
 @RestController
 @RequestMapping("/public")
-@CrossOrigin(origins = { "http://192.168.0.17:3000", "http://192.168.0.24:3000" })
+@CrossOrigin(origins = { "http://192.168.0.18:3000", "http://192.168.0.24:3000" })
 public class PublicController {
 
@@ -95,3 +97,13 @@
         return mainService.getCityById(cityId); // vrakja grad spored id
     }
+
+    @RequestMapping(value = "/loginSuccessRegular", method = RequestMethod.GET)
+    public Map<String, String> loginSuccessRegular(@RequestParam String sessionId) {
+        return Collections.singletonMap("sessionId", sessionId);
+    }
+
+    @RequestMapping(value = "/loginSuccessModerator", method = RequestMethod.GET)
+    public Map<String, String> loginSuccessModerator(@RequestParam String sessionId) {
+        return Collections.singletonMap("sessionId", sessionId);
+    }
 }
Index: springapp/src/main/java/mk/profesori/springapp/Controller/SecureController.java
===================================================================
--- springapp/src/main/java/mk/profesori/springapp/Controller/SecureController.java	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ springapp/src/main/java/mk/profesori/springapp/Controller/SecureController.java	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -1,3 +1,6 @@
 package mk.profesori.springapp.Controller;
+
+import java.util.Collections;
+import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -5,4 +8,5 @@
 import org.springframework.security.core.annotation.CurrentSecurityContext;
 import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -10,4 +14,5 @@
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -15,13 +20,16 @@
 
 import mk.profesori.springapp.Model.CustomUserDetails;
+import mk.profesori.springapp.Service.CustomUserDetailsService;
 import mk.profesori.springapp.Service.MainService;
 
 @RestController
 @RequestMapping("/secure")
-@CrossOrigin(origins = { "http://192.168.0.17:3000", "http://192.168.0.24:3000" })
+@CrossOrigin(origins = { "http://192.168.0.18:3000", "http://192.168.0.24:3000" })
 public class SecureController {
 
     @Autowired
     private MainService mainService;
+    @Autowired
+    CustomUserDetailsService customUserDetailsService;
 
     @RequestMapping(value = "/professor/{professorId}/addOpinion", method = RequestMethod.POST)
@@ -52,3 +60,15 @@
     }
 
+    @RequestMapping(value = "/user", method = RequestMethod.GET)
+    public UserDetails getUserDetails(@CurrentSecurityContext SecurityContext context) {
+
+        Authentication authentication = context.getAuthentication();
+        if (authentication != null && authentication.getPrincipal() instanceof CustomUserDetails) {
+            CustomUserDetails currentUser = (CustomUserDetails) authentication.getPrincipal();
+            return customUserDetailsService.loadUserByUsername(currentUser.getEmail());
+        }
+
+        return null;
+    }
+
 }
Index: springapp/src/main/java/mk/profesori/springapp/Model/CustomUserDetails.java
===================================================================
--- springapp/src/main/java/mk/profesori/springapp/Model/CustomUserDetails.java	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ springapp/src/main/java/mk/profesori/springapp/Model/CustomUserDetails.java	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -53,5 +53,5 @@
     private Set<ConfirmationToken> confirmationTokens = new HashSet<>();
     @OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
-    private List<Post> authoredPosts = new ArrayList<>();
+    private Set<Post> authoredPosts = new HashSet<>();
 
     public CustomUserDetails(String fullName, String username, String email, String password, UserRole userRole) {
@@ -99,5 +99,5 @@
     }
 
-    List<Post> getAuthoredPosts() {
+    public Set<Post> getAuthoredPosts() {
         return this.authoredPosts;
     }
Index: springapp/src/main/java/mk/profesori/springapp/Security/CustomAuthenticationSuccessHandler.java
===================================================================
--- springapp/src/main/java/mk/profesori/springapp/Security/CustomAuthenticationSuccessHandler.java	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
+++ springapp/src/main/java/mk/profesori/springapp/Security/CustomAuthenticationSuccessHandler.java	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -0,0 +1,79 @@
+package mk.profesori.springapp.Security;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.web.DefaultRedirectStrategy;
+import org.springframework.security.web.RedirectStrategy;
+import org.springframework.security.web.WebAttributes;
+import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
+
+public class CustomAuthenticationSuccessHandler
+    implements AuthenticationSuccessHandler {
+
+  protected Log logger = LogFactory.getLog(this.getClass());
+
+  private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
+
+  @Override
+  public void onAuthenticationSuccess(HttpServletRequest request,
+      HttpServletResponse response, Authentication authentication)
+      throws IOException {
+
+    handle(request, response, authentication);
+    clearAuthenticationAttributes(request);
+  }
+
+  protected void handle(
+      HttpServletRequest request,
+      HttpServletResponse response,
+      Authentication authentication) throws IOException {
+
+    String targetUrl = determineTargetUrl(authentication, request.getSession().getId());
+
+    if (response.isCommitted()) {
+      logger.debug(
+          "Response has already been committed. Unable to redirect to "
+              + targetUrl);
+      return;
+    }
+
+    redirectStrategy.sendRedirect(request, response, targetUrl);
+  }
+
+  protected String determineTargetUrl(final Authentication authentication, String sessionId) {
+
+    Map<String, String> roleTargetUrlMap = new HashMap<>();
+    roleTargetUrlMap.put("REGULAR", "/public/loginSuccessRegular?sessionId=" + sessionId);
+    roleTargetUrlMap.put("MODERATOR", "/public/loginSuccessModerator?sessionId=" + sessionId);
+
+    final Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
+    for (final GrantedAuthority grantedAuthority : authorities) {
+      String authorityName = grantedAuthority.getAuthority();
+      if (roleTargetUrlMap.containsKey(authorityName)) {
+        return roleTargetUrlMap.get(authorityName);
+      }
+    }
+
+    throw new IllegalStateException();
+  }
+
+  protected void clearAuthenticationAttributes(HttpServletRequest request) {
+    HttpSession session = request.getSession(false);
+    if (session == null) {
+      return;
+    }
+    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
+  }
+
+}
Index: springapp/src/main/java/mk/profesori/springapp/Security/SecurityConfiguration.java
===================================================================
--- springapp/src/main/java/mk/profesori/springapp/Security/SecurityConfiguration.java	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ springapp/src/main/java/mk/profesori/springapp/Security/SecurityConfiguration.java	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -10,4 +10,5 @@
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.security.web.SecurityFilterChain;
+import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -36,7 +37,13 @@
             @Override
             public void addCorsMappings(CorsRegistry registry) {
-                registry.addMapping("/**").allowedOrigins("http://192.168.0.17:3000", "http://192.168.0.24:3000");
+                registry.addMapping("/**").allowedOrigins("http://192.168.0.18:3000", "http://192.168.0.24:3000")
+                        .allowCredentials(true);
             }
         };
+    }
+
+    @Bean
+    public AuthenticationSuccessHandler customAuthenticationSuccessHandler() {
+        return new CustomAuthenticationSuccessHandler();
     }
 
@@ -54,5 +61,5 @@
                 .antMatchers("/registration/**").permitAll()
                 .and()
-                .formLogin();
+                .formLogin().successHandler(customAuthenticationSuccessHandler());
 
         return http.build();
Index: springapp/src/main/java/mk/profesori/springapp/Service/RegistrationService.java
===================================================================
--- springapp/src/main/java/mk/profesori/springapp/Service/RegistrationService.java	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ springapp/src/main/java/mk/profesori/springapp/Service/RegistrationService.java	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -25,47 +25,49 @@
     private final EmailSender emailSender;
     private final UserRepository userRepository;
-    
+
     public String register(RegistrationRequest request) {
 
         boolean isValidEmail = emailValidator.test(request.getEmail());
-        if(!isValidEmail) throw new IllegalStateException("Invalid email");
+        if (!isValidEmail)
+            throw new IllegalStateException("Invalid email");
 
         boolean isValidPassword = passwordValidator.test(request.getPassword());
-        if(!isValidPassword) throw new IllegalStateException("Invalid password");
+        if (!isValidPassword)
+            throw new IllegalStateException("Invalid password");
 
         boolean isValidUsername = usernameValidator.test(request.getUsername());
-        if(!isValidUsername) throw new IllegalStateException("Invalid username");
+        if (!isValidUsername)
+            throw new IllegalStateException("Invalid username");
 
         boolean emailExists = userRepository.findByEmail(request.getEmail()).isPresent();
-        if(emailExists) {
-            if(!userRepository.findByEmail(request.getEmail()).get().isEnabled()) {
-                String tokenToResend = customUserDetailsService.createToken(userRepository.findByEmail(request.getEmail()).get());
-                String link = "http://192.168.0.17:8080/registration/confirm?token=" + tokenToResend;
+        if (emailExists) {
+            if (!userRepository.findByEmail(request.getEmail()).get().isEnabled()) {
+                String tokenToResend = customUserDetailsService
+                        .createToken(userRepository.findByEmail(request.getEmail()).get());
+                String link = "http://192.168.0.18:8080/registration/confirm?token=" + tokenToResend;
                 emailSender.send(request.getEmail(), emailSender.buildEmail(request.getUsername(), link));
-                return tokenToResend; 
+                return tokenToResend;
             } else {
-            throw new IllegalStateException("Email is taken");
+                throw new IllegalStateException("Email is taken");
             }
         }
 
         boolean usernameExists = userRepository.findByUsername(request.getUsername()).isPresent();
-        if(usernameExists) {
+        if (usernameExists) {
             throw new IllegalStateException("Username is taken");
         }
 
         String token = customUserDetailsService.signUp(
-            new CustomUserDetails(
-                request.getFullName(),
-                request.getUsername(),
-                request.getEmail(),
-                request.getPassword(),
-                UserRole.REGULAR
-            )
-            );
-        
-        String link = "http://192.168.0.17:8080/registration/confirm?token=" + token;
-        
+                new CustomUserDetails(
+                        request.getFullName(),
+                        request.getUsername(),
+                        request.getEmail(),
+                        request.getPassword(),
+                        UserRole.REGULAR));
+
+        String link = "http://192.168.0.18:8080/registration/confirm?token=" + token;
+
         emailSender.send(request.getEmail(), emailSender.buildEmail(request.getUsername(), link));
-        
+
         return token;
     }
@@ -75,6 +77,5 @@
         ConfirmationToken confirmationToken = confirmationTokenService
                 .getToken(token)
-                .orElseThrow(() ->
-                        new IllegalStateException("Token not found"));
+                .orElseThrow(() -> new IllegalStateException("Token not found"));
 
         if (confirmationToken.getConfirmedAt() != null) {
