Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserService activateRegistration method didn't set activation key properly #268

Open
1 task done
kevintanhongann opened this issue Aug 18, 2022 · 0 comments
Open
1 task done

Comments

@kevintanhongann
Copy link
Contributor

kevintanhongann commented Aug 18, 2022

Overview of the issue
Reproduce the error
  1. Go through register
  2. Go through activation
  3. Login will be unsuccessful.
Related issues

N/A

Suggest a Fix
public Optional<User> activateRegistration(String key) {
    log.debug("Activating user for activation key {}", key);
    return userRepository
      .findOneByActivationKey(key)
      .map(user -> {
        // activate given user for the registration key.
        user.setActivated(true);
        user.setActivationKey(null);
        this.clearUserCaches(user);
        log.debug("Activated user: {}", user);
        return user;
      });
  }

to

public Optional<User> activateRegistration(String key) {
    log.debug("Activating user for activation key {}", key);
    return userRepository
      .findOneByActivationKey(key)
      .map(user -> {
        // activate given user for the registration key.
        user.setActivated(true);
        user.setActivationKey(key); //the key should be set here.
        this.clearUserCaches(user);
        log.debug("Activated user: {}", user);
        return user;
      });
  }

Project configuration

Any project that doesn't use third party auth.

Entity configuration(s) entityName.json files generated in the .jhipster directory

N/A

Browsers and Operating System

Any

  • Checking this box is mandatory (this is just to show you read everything)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant