congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
VerificationCode
Code IndexAdd Tabnine to your IDE (free)

How to use
VerificationCode
in
me.zhengjie.domain

Best Java code snippets using me.zhengjie.domain.VerificationCode (Showing top 6 results out of 315)

origin: elunez/eladmin

@PostMapping(value = "/code/email/resetPass")
public ResponseEntity resetPass(@RequestParam String email) throws Exception {
  VerificationCode code = new VerificationCode();
  code.setType("email");
  code.setValue(email);
  code.setScenes(ElAdminConstant.RESET_MAIL);
  EmailVo emailVo = verificationCodeService.sendEmail(code);
  emailService.send(emailVo,emailService.find());
  return new ResponseEntity(HttpStatus.OK);
}
origin: elunez/eladmin

@Override
public void validated(VerificationCode code) {
  VerificationCode verificationCode = verificationCodeRepository.findByScenesAndTypeAndValueAndStatusIsTrue(code.getScenes(),code.getType(),code.getValue());
  if(verificationCode == null || !verificationCode.getCode().equals(code.getCode())){
    throw new BadRequestException("无效验证码");
  } else {
    verificationCode.setStatus(false);
    verificationCodeRepository.save(verificationCode);
  }
}
origin: elunez/eladmin

@Override
@Transactional(rollbackFor = Exception.class)
public EmailVo sendEmail(VerificationCode code) {
  EmailVo emailVo = null;
  String content = "";
  VerificationCode verificationCode = verificationCodeRepository.findByScenesAndTypeAndValueAndStatusIsTrue(code.getScenes(),code.getType(),code.getValue());
  // 如果不存在有效的验证码,就创建一个新的
  TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH));
  Template template = engine.getTemplate("email/email.ftl");
  if(verificationCode == null){
    code.setCode(RandomUtil.randomNumbers (6));
    content = template.render(Dict.create().set("code",code.getCode()));
    emailVo = new EmailVo(Arrays.asList(code.getValue()),"eladmin后台管理系统",content);
    timedDestruction(verificationCodeRepository.save(code));
  // 存在就再次发送原来的验证码
  } else {
    content = template.render(Dict.create().set("code",verificationCode.getCode()));
    emailVo = new EmailVo(Arrays.asList(verificationCode.getValue()),"eladmin后台管理系统",content);
  }
  return emailVo;
}
origin: elunez/eladmin

  /**
   * 修改邮箱
   * @param user
   * @param user
   * @return
   */
  @PostMapping(value = "/users/updateEmail/{code}")
  public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user){
    UserDetails userDetails = SecurityContextHolder.getUserDetails();
    JwtUser jwtUser = (JwtUser)userDetailsService.loadUserByUsername(userDetails.getUsername());
    if(!jwtUser.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
      throw new BadRequestException("密码错误");
    }
    VerificationCode verificationCode = new VerificationCode(code, ElAdminConstant.RESET_MAIL,"email",user.getEmail());
    verificationCodeService.validated(verificationCode);
    userService.updateEmail(jwtUser,user.getEmail());
    return new ResponseEntity(HttpStatus.OK);
  }
}
origin: elunez/eladmin

  /**
   * 定时任务,指定分钟后改变验证码状态
   * @param verifyCode
   */
  private void timedDestruction(VerificationCode verifyCode) {
    //以下示例为程序调用结束继续运行
    ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
    try {
      executorService.schedule(() -> {
        verifyCode.setStatus(false);
        verificationCodeRepository.save(verifyCode);
      }, expiration * 60 * 1000L, TimeUnit.MILLISECONDS);
    }catch (Exception e){
      e.printStackTrace();
    }
  }
}
origin: elunez/eladmin

@PostMapping(value = "/code/resetEmail")
public ResponseEntity resetEmail(@RequestBody VerificationCode code) throws Exception {
  code.setScenes(ElAdminConstant.RESET_MAIL);
  EmailVo emailVo = verificationCodeService.sendEmail(code);
  emailService.send(emailVo,emailService.find());
  return new ResponseEntity(HttpStatus.OK);
}
me.zhengjie.domainVerificationCode

Most used methods

  • <init>
  • getCode
  • getScenes
  • getType
  • getValue
  • setCode
  • setScenes
  • setStatus
  • setType
  • setValue

Popular in Java

  • Running tasks concurrently on multiple threads
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Option (scala)
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now