Changeset - b63adad7c4af
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 14 years ago 2012-02-21 01:35:43
marcin@python-works.com
API updates
- update_user will do lookup by userid param that can be id or username
- all params are required for update_user api call
- get_user/s will return ldap_dn param which is more correct
3 files changed with 16 insertions and 12 deletions:
0 comments (0 inline, 0 general)
docs/api/api.rst
Show inline comments
 
@@ -111,7 +111,7 @@ OUTPUT::
 
                "email" :    "<email>",
 
                "active" :   "<bool>",
 
                "admin" :    "<bool>",
 
                "ldap" :     "<ldap_dn>"
 
                "ldap_dn" :  "<ldap_dn>"
 
            }
 

	
 
    error:  null
 
@@ -141,7 +141,7 @@ OUTPUT::
 
                "email" :    "<email>",
 
                "active" :   "<bool>",
 
                "admin" :    "<bool>",
 
                "ldap" :     "<ldap_dn>"
 
                "ldap_dn" :  "<ldap_dn>"
 
              },
 
    	
 
            ]
 
@@ -191,14 +191,15 @@ INPUT::
 
    api_key : "<api_key>"
 
    method :  "update_user"
 
    args :    {
 
                "userid" : "<user_id or username>",
 
                "username" :  "<username>",
 
                "password" :  "<password>",
 
                "email" :     "<useremail>",
 
                "firstname" : "<firstname> = None",
 
                "lastname" :  "<lastname> = None",
 
                "active" :    "<bool> = True",
 
                "admin" :     "<bool> = False",
 
                "ldap_dn" :   "<ldap_dn> = None"
 
                "firstname" : "<firstname>",
 
                "lastname" :  "<lastname>",
 
                "active" :    "<bool>",
 
                "admin" :     "<bool>",
 
                "ldap_dn" :   "<ldap_dn>"
 
              }
 

	
 
OUTPUT::
rhodecode/controllers/api/api.py
Show inline comments
 
@@ -100,7 +100,7 @@ class ApiController(JSONRPCController):
 
            email=user.email,
 
            active=user.active,
 
            admin=user.admin,
 
            ldap=user.ldap_dn
 
            ldap_dn=user.ldap_dn
 
        )
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
@@ -122,7 +122,7 @@ class ApiController(JSONRPCController):
 
                    email=user.email,
 
                    active=user.active,
 
                    admin=user.admin,
 
                    ldap=user.ldap_dn
 
                    ldap_dn=user.ldap_dn
 
                )
 
            )
 
        return result
 
@@ -168,8 +168,8 @@ class ApiController(JSONRPCController):
 
            raise JSONRPCError('failed to create user %s' % username)
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def update_user(self, apiuser, username, password, email, firstname=None,
 
                    lastname=None, active=True, admin=False, ldap_dn=None):
 
    def update_user(self, apiuser, userid, username, password, email,
 
                    firstname, lastname, active, admin, ldap_dn):
 
        """
 
        Updates given user
 

	
 
@@ -183,7 +183,7 @@ class ApiController(JSONRPCController):
 
        :param admin:
 
        :param ldap_dn:
 
        """
 
        if not User.get_by_username(username):
 
        if not UserModel().get_user(userid):
 
            raise JSONRPCError("user %s does not exist" % username)
 

	
 
        try:
rhodecode/model/user.py
Show inline comments
 
@@ -74,6 +74,9 @@ class UserModel(BaseModel):
 
                                          "get_user_%s" % user_id))
 
        return user.get(user_id)
 

	
 
    def get_user(self, user):
 
        return self.__get_user(user)
 

	
 
    def get_by_username(self, username, cache=False, case_insensitive=False):
 

	
 
        if case_insensitive:
0 comments (0 inline, 0 general)