修复用户模块权限问题

This commit is contained in:
kerwincui
2021-07-30 14:48:20 +08:00
parent 0199758c7a
commit 829d1112e0
3 changed files with 31 additions and 4 deletions

View File

@@ -8,7 +8,8 @@
<version>3.4.0</version> <version>3.4.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging> <!-- jar部署pom war部署war-->
<packaging>war</packaging>
<artifactId>ruoyi-admin</artifactId> <artifactId>ruoyi-admin</artifactId>
<description> <description>

View File

@@ -124,7 +124,7 @@ public class SysUserController extends BaseController
/** /**
* 新增用户 * 新增用户
*/ */
// @PreAuthorize("@ss.hasPermi('system:user:add')") @PreAuthorize("@ss.hasPermi('system:user:add')")
@Log(title = "用户管理", businessType = BusinessType.INSERT) @Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
@ApiOperation(value = "新增用户", notes = "新增用户") @ApiOperation(value = "新增用户", notes = "新增用户")
@@ -149,6 +149,33 @@ public class SysUserController extends BaseController
return toAjax(userService.insertUser(user)); return toAjax(userService.insertUser(user));
} }
/**
* 用户注册
*/
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping("/register")
@ApiOperation(value = "用户注册", notes = "用户注册")
public AjaxResult register(@Validated @RequestBody SysUser user)
{
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setDelFlag("0");
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user));
}
/** /**
* 修改用户 * 修改用户
*/ */

View File

@@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 验证码captchaImage 允许匿名访问 // 对于登录login 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/captchaImage").anonymous() .antMatchers("/login", "/captchaImage","/system/user/register").anonymous()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,
"/*.html", "/*.html",
@@ -113,7 +113,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/webjars/**").anonymous() .antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous() .antMatchers("/*/api-docs").anonymous()
.antMatchers("/druid/**").anonymous() .antMatchers("/druid/**").anonymous()
.antMatchers("/system/user/**").anonymous()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()