Add ability to use email in Gitlab authentication

Review Request #5591 — Created March 8, 2014 and submitted

Information

Review Board
release-1.7.x
3fb29b2...

Reviewers

Older versions of Gitlab API v3 only allow authentication using email instead of "login" parameter that Review board currently uses.

See https://github.com/gitlabhq/gitlabhq/commit/559e83d30004e0c41a30f4ce3463f695eb7e26a1

Unit tests pass. Tested authentication with email againts different versions of Gitlab.

Description From Last Updated

Using the ternary here in the key name isn't particularly readable. How about pulling the key out into a variable …

daviddavid

This shouldn't be necessary. Just defining login_key inside the conditional is fine.

daviddavid
TO
TO
david
  1. 
      
  2. reviewboard/hostingsvcs/gitlab.py (Diff revision 1)
     
     
     
     
     
     
     

    Using the ternary here in the key name isn't particularly readable. How about pulling the key out into a variable and using a plain conditional?

    if self._is_email(username):
        login_key = 'email'
    else:
        login_key = 'login'
    
    rsp, headers = self._json_post(
        url=self._build_api_url(hosting_url, 'session'),
        fields={
            login_key: username,
            'password': password,
        })
    

    You could maybe even replace the conditional with try/except and get rid of the _is_email method.

  3. 
      
TO
david
  1. 
      
  2. reviewboard/hostingsvcs/gitlab.py (Diff revision 2)
     
     

    This shouldn't be necessary. Just defining login_key inside the conditional is fine.

  3. 
      
TO
TO
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-1.7.x (aa9e84b). Thanks!
Loading...