Skip to content

Commit

Permalink
Redirect homepage to profile if authenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
Nonononoki committed Mar 28, 2021
1 parent 2fcbdeb commit e5e324d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/java/com/nonononoki/alovoa/html/IndexResource.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
package com.nonononoki.alovoa.html;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import com.nonononoki.alovoa.entity.User;
import com.nonononoki.alovoa.service.AuthService;

@Controller
public class IndexResource {


@Autowired
private AuthService authService;

@Autowired
private ProfileResource profileResource;

@GetMapping("/")
public ModelAndView register() {
public ModelAndView index() throws Exception {

User user = authService.getCurrentUser();
if (user != null) {
return profileResource.profile();
}

ModelAndView mav = new ModelAndView("index");
return mav;
Expand Down

0 comments on commit e5e324d

Please sign in to comment.