-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathSecurityController.java
39 lines (34 loc) · 1.09 KB
/
SecurityController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.developersboard.web.controller;
import com.developersboard.constant.HomeConstants;
import com.developersboard.constant.SecurityConstants;
import com.developersboard.constant.user.UserConstants;
import com.developersboard.shared.util.core.SecurityUtils;
import com.developersboard.web.payload.request.LoginRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
/**
* The controller for handling all security-related mappings.
*
* @author Eric Opoku
* @version 1.0
* @since 1.0
*/
@Controller
public class SecurityController {
/**
* The login mapping.
*
* @param model the model
* @return the login page.
*/
@GetMapping(path = SecurityConstants.LOGIN)
public String login(Model model) {
// if the user is authenticated, redirect to the home page.
if (SecurityUtils.isAuthenticated()) {
return HomeConstants.REDIRECT_TO_INDEX;
}
model.addAttribute(UserConstants.USER_MODEL_KEY, new LoginRequest());
return SecurityConstants.LOGIN_VIEW_NAME;
}
}