#
luxiaotao1123
2025-02-13 b2666de54e7660d03a8748907055e00a3ba9ab2b
rsf-server/src/main/java/com/vincent/rsf/server/system/controller/AuthController.java
@@ -5,6 +5,7 @@
import com.vincent.rsf.framework.common.BaseRes;
import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.common.annotation.OperationLog;
import com.vincent.rsf.server.common.config.ConfigProperties;
import com.vincent.rsf.server.common.security.JwtSubject;
@@ -13,6 +14,7 @@
import com.vincent.rsf.server.common.utils.JwtUtil;
import com.vincent.rsf.server.system.controller.param.LoginParam;
import com.vincent.rsf.server.system.controller.param.RegisterParam;
import com.vincent.rsf.server.system.controller.param.TenantInitParam;
import com.vincent.rsf.server.system.controller.param.UpdatePasswordParam;
import com.vincent.rsf.server.system.controller.result.LoginResult;
import com.vincent.rsf.server.system.controller.result.MenuVo;
@@ -81,9 +83,12 @@
    }
    @GetMapping("/email/code")
    public R emailCode(@RequestParam("email") String email) {
    public R emailCode(@RequestParam(value = "email", required = false) String email) {
        if (Cools.isEmpty(email)) {
            return R.parse(BaseRes.PARAM);
        }
        if (!emailService.isValid(email)) {
            return R.error("Please enter a valid email address");
        }
        if (null != userService.getByEmail(email, null)) {
            return R.error("Email Already Exist");
@@ -113,22 +118,19 @@
        if (!cacheCode.equals(param.getCode())) {
            return R.error("The verification code is incorrect.");
        }
        redisService.delete(EmailType.REGISTER_VERIFY.toString(), param.getEmail());
        // register
        TenantInitParam initParam = new TenantInitParam();
        initParam.setEmail(param.getEmail());
        initParam.setUsername(param.getUsername());
        initParam.setPassword(param.getPassword());
        initParam.setName(param.getUsername());
        initParam.setFlag(param.getUsername());
        if (!tenantService.initTenant(initParam)) {
            throw new CoolException("Failed to register");
        }
//        User user = new User();
//        user.setUsername(param.getUsername());
//        user.setNickname(param.getUsername());
//        user.setPassword(userService.encodePassword(param.getPassword()));
//        user.setEmail(param.getEmail());
//        user.setEmailVerified(1);
//        user.setStatus(StatusType.ENABLE.val);
//        user.setCreateTime(new Date());
//        if (!userService.save(user)) {
//            throw new CoolException("");
//        }
        redisService.delete(EmailType.REGISTER_VERIFY.toString(), param.getEmail());
        return R.ok();
    }