Show More
@@ -151,7 +151,7 b' OUTPUT::' | |||
|
151 | 151 | create_user |
|
152 | 152 | ----------- |
|
153 | 153 | |
|
154 |
Creates new user |
|
|
154 | Creates new user. This command can | |
|
155 | 155 | be executed only using api_key belonging to user with admin rights. |
|
156 | 156 | |
|
157 | 157 | |
@@ -179,6 +179,37 b' OUTPUT::' | |||
|
179 | 179 | error: null |
|
180 | 180 | |
|
181 | 181 | |
|
182 | update_user | |
|
183 | ----------- | |
|
184 | ||
|
185 | updates current one if such user exists. This command can | |
|
186 | be executed only using api_key belonging to user with admin rights. | |
|
187 | ||
|
188 | ||
|
189 | INPUT:: | |
|
190 | ||
|
191 | api_key : "<api_key>" | |
|
192 | method : "update_user" | |
|
193 | args : { | |
|
194 | "username" : "<username>", | |
|
195 | "password" : "<password>", | |
|
196 | "email" : "<useremail>", | |
|
197 | "firstname" : "<firstname> = None", | |
|
198 | "lastname" : "<lastname> = None", | |
|
199 | "active" : "<bool> = True", | |
|
200 | "admin" : "<bool> = False", | |
|
201 | "ldap_dn" : "<ldap_dn> = None" | |
|
202 | } | |
|
203 | ||
|
204 | OUTPUT:: | |
|
205 | ||
|
206 | result: { | |
|
207 | "id" : "<edited_user_id>", | |
|
208 | "msg" : "updated user <username>" | |
|
209 | } | |
|
210 | error: null | |
|
211 | ||
|
212 | ||
|
182 | 213 | get_users_group |
|
183 | 214 | --------------- |
|
184 | 215 |
@@ -134,7 +134,7 b' class ApiController(JSONRPCController):' | |||
|
134 | 134 | def create_user(self, apiuser, username, password, email, firstname=None, |
|
135 | 135 | lastname=None, active=True, admin=False, ldap_dn=None): |
|
136 | 136 | """ |
|
137 |
Create new user |
|
|
137 | Create new user | |
|
138 | 138 | |
|
139 | 139 | :param apiuser: |
|
140 | 140 | :param username: |
@@ -146,7 +146,6 b' class ApiController(JSONRPCController):' | |||
|
146 | 146 | :param admin: |
|
147 | 147 | :param ldap_dn: |
|
148 | 148 | """ |
|
149 | ||
|
150 | 149 | if User.get_by_username(username): |
|
151 | 150 | raise JSONRPCError("user %s already exist" % username) |
|
152 | 151 | |
@@ -165,6 +164,39 b' class ApiController(JSONRPCController):' | |||
|
165 | 164 | raise JSONRPCError('failed to create user %s' % username) |
|
166 | 165 | |
|
167 | 166 | @HasPermissionAllDecorator('hg.admin') |
|
167 | def update_user(self, apiuser, username, password, email, firstname=None, | |
|
168 | lastname=None, active=True, admin=False, ldap_dn=None): | |
|
169 | """ | |
|
170 | Updates given user | |
|
171 | ||
|
172 | :param apiuser: | |
|
173 | :param username: | |
|
174 | :param password: | |
|
175 | :param email: | |
|
176 | :param name: | |
|
177 | :param lastname: | |
|
178 | :param active: | |
|
179 | :param admin: | |
|
180 | :param ldap_dn: | |
|
181 | """ | |
|
182 | if not User.get_by_username(username): | |
|
183 | raise JSONRPCError("user %s does not exist" % username) | |
|
184 | ||
|
185 | try: | |
|
186 | usr = UserModel().create_or_update( | |
|
187 | username, password, email, firstname, | |
|
188 | lastname, active, admin, ldap_dn | |
|
189 | ) | |
|
190 | Session.commit() | |
|
191 | return dict( | |
|
192 | id=usr.user_id, | |
|
193 | msg='updated user %s' % username | |
|
194 | ) | |
|
195 | except Exception: | |
|
196 | log.error(traceback.format_exc()) | |
|
197 | raise JSONRPCError('failed to update user %s' % username) | |
|
198 | ||
|
199 | @HasPermissionAllDecorator('hg.admin') | |
|
168 | 200 | def get_users_group(self, apiuser, group_name): |
|
169 | 201 | """" |
|
170 | 202 | Get users group by name |
General Comments 0
You need to be logged in to leave comments.
Login now