Skip to content

Commit

Permalink
Fix some problem
Browse files Browse the repository at this point in the history
1. use post instead of get for auth/login api
2. refactor api filter, but still need to work on it
3. if login failed show some message in front end
  • Loading branch information
wfnuser committed Jan 9, 2019
1 parent d09c0e5 commit 2db55b1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public void configure(WebSecurity web) {
// TODO: we should use a better way to match the resources
// requests for resource and auth api are always allowed
web.ignoring()
.antMatchers("/", "/*.html", "/**/*.js", "/**/*.css", "/favicon.ico", "/**/*.html", "/**/*.map", "/**/*.svg", "/console-fe/public/*", "/**/*.png", "/*.png")
.antMatchers("/")
.antMatchers("/**/*.css", "/**/*.js", "/**/*.html", "/**/*.map", "/**/*.svg", "/**/*.png", "/**/*.ico")
.antMatchers("/**.css", "/**.js", "/**.html", "/**.map", "/**.svg", "/**.png", "/**.ico")
.antMatchers("/console-fe/public/*")
.antMatchers("/v1/auth/login")
.antMatchers("/v1/cs/health");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ public class AuthController {
*/

@ResponseBody
@RequestMapping(value = "login", method = RequestMethod.GET)
public RestResult<String> login(HttpServletRequest request, HttpServletResponse response,
@RequestParam("username") String username,
@RequestParam("password") String password) throws Exception {
@RequestMapping(value = "login", method = RequestMethod.POST)
public RestResult<String> login(HttpServletRequest request, HttpServletResponse response) throws Exception {
String username = request.getParameter("username");
String password = request.getParameter("password");

// 通过用户名和密码创建一个 Authentication 认证对象,实现类为 UsernamePasswordAuthenticationToken
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
RestResult<String> rr = new RestResult<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Login extends React.Component {
handleSubmit = values => {
const { locale = {} } = this.props;
request({
type: 'get',
type: 'post',
url: 'v1/auth/login',
data: values,
success: res => {
Expand Down
4 changes: 2 additions & 2 deletions console/src/main/resources/static/js/main.js

Large diffs are not rendered by default.

0 comments on commit 2db55b1

Please sign in to comment.