通过令牌激活新帐户

时间:2018-06-06 17:05:44

标签: java spring spring-boot

我有一个保存nes用户的api,我希望当有人进行保存时,会向他发送包含激活链接的邮件。该链接包含验证令牌。我的问题是生成此令牌的最佳方法是什么,我看到了一些uuid的例子,但我发现我可以使用oauth2生成令牌

@PostMapping
    public ResponseEntity<UserDto> createNewUser(@RequestBody @Valid final UserDto userDto) throws URISyntaxException {
        UserDto userExists = userService.findUserByEmail(userDto.getEmail());
        if (userExists != null) {
            throw new UserExistsException(User.class, "email", userDto.getEmail());
        }
        UserDto user = userService.createUserAccount(userDto);
        LOGGER.debug("Registering user account with information: {}", userDto);
        return ResponseEntity.created(new URI("/api/profile/" + userDto.getEmail())).body(user);
    }

0 个答案:

没有答案