github: Add sign up button on registration page.

This commit is contained in:
Umair Khan 2017-04-18 14:50:44 +05:00 committed by Tim Abbott
parent d56db0a3b4
commit dc2a9a4c5b
4 changed files with 29 additions and 1 deletions

View File

@ -65,15 +65,28 @@ $(function () {
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if google_auth_enabled %} {% if any_oauth_backend_enabled %}
<div class="or">or</div> <div class="or">or</div>
{% endif %}
{% if google_auth_enabled %}
<div class="register-google"> <div class="register-google">
<a href="{{ url('zerver.views.auth.start_google_oauth2') }}"> <a href="{{ url('zerver.views.auth.start_google_oauth2') }}">
<button class="login-google-button full-width">{{ _('Sign up with Google') }}</button> <button class="login-google-button full-width">{{ _('Sign up with Google') }}</button>
</a> </a>
</div> </div>
{% endif %} {% endif %}
{% if github_auth_enabled %}
<div class="login-github">
<a href="{{ url('signup-social', args=('github',)) }}"
class="github-wrapper">
<button class="login-github-button github">
<span>{{ _('Sign up with GitHub') }}</span>
</button>
</a>
</div>
{% endif %}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@ -677,6 +677,13 @@ class GitHubAuthBackendTest(ZulipTestCase):
# type: () -> None # type: () -> None
result = self.client_get('/accounts/login/social/github') result = self.client_get('/accounts/login/social/github')
self.assertIn(reverse('social:begin', args=['github']), result.url) self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=0', result.url)
def test_signup_url(self):
# type: () -> None
result = self.client_get('/accounts/register/social/github')
self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=1', result.url)
def test_github_complete(self): def test_github_complete(self):
# type: () -> None # type: () -> None

View File

@ -233,6 +233,11 @@ def start_social_login(request, backend):
backend_url = reverse('social:begin', args=[backend]) backend_url = reverse('social:begin', args=[backend])
return redirect_to_main_site(request, backend_url) return redirect_to_main_site(request, backend_url)
def start_social_signup(request, backend):
# type: (HttpRequest, Text) -> HttpResponse
backend_url = reverse('social:begin', args=[backend])
return redirect_to_main_site(request, backend_url, is_signup=True)
def send_oauth_request_to_google(request): def send_oauth_request_to_google(request):
# type: (HttpRequest) -> HttpResponse # type: (HttpRequest) -> HttpResponse
subdomain = request.GET.get('subdomain', '') subdomain = request.GET.get('subdomain', '')

View File

@ -101,6 +101,9 @@ i18n_urls = [
url(r'^avatar/(?P<email_or_id>[\S]+)?', zerver.views.users.avatar, name='zerver.views.users.avatar'), url(r'^avatar/(?P<email_or_id>[\S]+)?', zerver.views.users.avatar, name='zerver.views.users.avatar'),
# Registration views, require a confirmation ID. # Registration views, require a confirmation ID.
url(r'^accounts/register/social/(\w+)$',
zerver.views.auth.start_social_signup,
name='signup-social'),
url(r'^accounts/home/', zerver.views.registration.accounts_home, url(r'^accounts/home/', zerver.views.registration.accounts_home,
name='zerver.views.registration.accounts_home'), name='zerver.views.registration.accounts_home'),
url(r'^accounts/send_confirm/(?P<email>[\S]+)?', url(r'^accounts/send_confirm/(?P<email>[\S]+)?',