Signup form: prefill username if Discourse Hub has a match for the email address. Also, fix some bad specs in username_checker_service_spec that were passing...

This commit is contained in:
Neil Lalonde
2013-11-19 14:15:05 -05:00
parent 309904ef8f
commit 981d8f6aea
8 changed files with 148 additions and 64 deletions

View File

@@ -32,6 +32,11 @@ module DiscourseHub
[json['match'], json['available'] || false, json['suggestion']]
end
def self.nickname_for_email(email)
json = get('/users/nickname_match', {email: email})
json['suggestion']
end
def self.register_nickname(nickname, email)
json = post('/users', {nickname: nickname, email: email})
if json.has_key?('success')
@@ -100,7 +105,7 @@ module DiscourseHub
if Rails.env == 'production'
'http://api.discourse.org/api'
else
'http://local.hub:3000/api'
ENV['HUB_BASE_URL'] || 'http://local.hub:3000/api'
end
end