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

Full username_available? method #3

Closed
2 tasks done
ngsankha opened this issue Oct 17, 2019 · 1 comment
Closed
2 tasks done

Full username_available? method #3

ngsankha opened this issue Oct 17, 2019 · 1 comment

Comments

@ngsankha
Copy link
Owner

ngsankha commented Oct 17, 2019

Finally get to synthesis of something like:

  def self.username_available?(username, email = nil)
    lower = username.downcase
    return false if reserved_username?(lower)
    return true  if !User.exists?(username_lower: lower)
    # staged users can use the same username since they will take over the account
    email.present? && User.joins(:user_emails).exists?(staged: true, username_lower: lower, user_emails: { primary: true, email: email })
  end

Blockers:

@ngsankha ngsankha changed the title [Meta] Full username_available? method Full username_available? method Oct 30, 2019
@ngsankha
Copy link
Owner Author

We are basically there. The tests in the Discourse app are underspecified - so the synthesizer gives some other program. Need to come up with a good test.

@ngsankha ngsankha closed this as completed Mar 6, 2020
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