##// END OF EJS Templates
API updates...
marcink -
r2009:b63adad7 beta
parent child Browse files
Show More
@@ -111,7 +111,7 b' OUTPUT::'
111 "email" : "<email>",
111 "email" : "<email>",
112 "active" : "<bool>",
112 "active" : "<bool>",
113 "admin" :  "<bool>",
113 "admin" :  "<bool>",
114 "ldap" : "<ldap_dn>"
114 "ldap_dn" : "<ldap_dn>"
115 }
115 }
116
116
117 error: null
117 error: null
@@ -141,7 +141,7 b' OUTPUT::'
141 "email" : "<email>",
141 "email" : "<email>",
142 "active" : "<bool>",
142 "active" : "<bool>",
143 "admin" :  "<bool>",
143 "admin" :  "<bool>",
144 "ldap" : "<ldap_dn>"
144 "ldap_dn" : "<ldap_dn>"
145 },
145 },
146
146
147 ]
147 ]
@@ -191,14 +191,15 b' INPUT::'
191 api_key : "<api_key>"
191 api_key : "<api_key>"
192 method : "update_user"
192 method : "update_user"
193 args : {
193 args : {
194 "userid" : "<user_id or username>",
194 "username" : "<username>",
195 "username" : "<username>",
195 "password" : "<password>",
196 "password" : "<password>",
196 "email" : "<useremail>",
197 "email" : "<useremail>",
197 "firstname" : "<firstname> = None",
198 "firstname" : "<firstname>",
198 "lastname" : "<lastname> = None",
199 "lastname" : "<lastname>",
199 "active" : "<bool> = True",
200 "active" : "<bool>",
200 "admin" : "<bool> = False",
201 "admin" : "<bool>",
201 "ldap_dn" : "<ldap_dn> = None"
202 "ldap_dn" : "<ldap_dn>"
202 }
203 }
203
204
204 OUTPUT::
205 OUTPUT::
@@ -100,7 +100,7 b' class ApiController(JSONRPCController):'
100 email=user.email,
100 email=user.email,
101 active=user.active,
101 active=user.active,
102 admin=user.admin,
102 admin=user.admin,
103 ldap=user.ldap_dn
103 ldap_dn=user.ldap_dn
104 )
104 )
105
105
106 @HasPermissionAllDecorator('hg.admin')
106 @HasPermissionAllDecorator('hg.admin')
@@ -122,7 +122,7 b' class ApiController(JSONRPCController):'
122 email=user.email,
122 email=user.email,
123 active=user.active,
123 active=user.active,
124 admin=user.admin,
124 admin=user.admin,
125 ldap=user.ldap_dn
125 ldap_dn=user.ldap_dn
126 )
126 )
127 )
127 )
128 return result
128 return result
@@ -168,8 +168,8 b' class ApiController(JSONRPCController):'
168 raise JSONRPCError('failed to create user %s' % username)
168 raise JSONRPCError('failed to create user %s' % username)
169
169
170 @HasPermissionAllDecorator('hg.admin')
170 @HasPermissionAllDecorator('hg.admin')
171 def update_user(self, apiuser, username, password, email, firstname=None,
171 def update_user(self, apiuser, userid, username, password, email,
172 lastname=None, active=True, admin=False, ldap_dn=None):
172 firstname, lastname, active, admin, ldap_dn):
173 """
173 """
174 Updates given user
174 Updates given user
175
175
@@ -183,7 +183,7 b' class ApiController(JSONRPCController):'
183 :param admin:
183 :param admin:
184 :param ldap_dn:
184 :param ldap_dn:
185 """
185 """
186 if not User.get_by_username(username):
186 if not UserModel().get_user(userid):
187 raise JSONRPCError("user %s does not exist" % username)
187 raise JSONRPCError("user %s does not exist" % username)
188
188
189 try:
189 try:
@@ -74,6 +74,9 b' class UserModel(BaseModel):'
74 "get_user_%s" % user_id))
74 "get_user_%s" % user_id))
75 return user.get(user_id)
75 return user.get(user_id)
76
76
77 def get_user(self, user):
78 return self.__get_user(user)
79
77 def get_by_username(self, username, cache=False, case_insensitive=False):
80 def get_by_username(self, username, cache=False, case_insensitive=False):
78
81
79 if case_insensitive:
82 if case_insensitive:
General Comments 0
You need to be logged in to leave comments. Login now