TG-59 : TU sur UserAPI + corrections
This commit is contained in:
@ -74,7 +74,7 @@ class GroupAPI(Resource):
|
||||
return {"ERROR": "This group does not exists !"}, 405
|
||||
|
||||
group = getGroup(name=name)
|
||||
if group is None:
|
||||
if group is not None:
|
||||
return {"ERROR": "A group with this name already exists !"}, 405
|
||||
|
||||
user = getUser(uid=resp_id)
|
||||
|
@ -22,6 +22,9 @@ class UserAPI(Resource):
|
||||
if user is not None:
|
||||
return {"UID": user["id"]}, 200
|
||||
|
||||
if getUser(email=email) is not None:
|
||||
return {"ERROR": "A user with this email (" + email + ") already exists !"}, 405
|
||||
|
||||
query = USER.insert().values(login=CASid, email=email, role=role, phone=phone)
|
||||
res = query.execute()
|
||||
return {"UID": res.lastrowid}, 201
|
||||
@ -31,13 +34,20 @@ class UserAPI(Resource):
|
||||
if not checkParams(['CASid', 'role', 'email', 'phone'], args):
|
||||
return {"ERROR": "One or more parameters are missing !"}, 400
|
||||
|
||||
if getUser(uid=uid) is None:
|
||||
return {"ERROR": "This user doesn't exists !"}, 405
|
||||
|
||||
CASid = args['CASid']
|
||||
role = args['role']
|
||||
email = args['email']
|
||||
phone = args['phone']
|
||||
|
||||
if getUser(uid=uid) is None:
|
||||
return {"ERROR": "This user doesn't exists !"}, 405
|
||||
|
||||
if getUser(login=CASid) is not None:
|
||||
return {"ERROR": "A user with this CASid (login) already exists !"}, 405
|
||||
|
||||
if getUser(email=email) is not None:
|
||||
return {"ERROR": "A user with this email already exists !"}, 405
|
||||
|
||||
query = USER.update().values(login=CASid, email=email, role=role, phone=phone).where(USER.c.id == uid)
|
||||
query.execute()
|
||||
return {"UID": uid}, 200
|
||||
@ -52,4 +62,4 @@ class UserAPI(Resource):
|
||||
|
||||
@staticmethod
|
||||
def getEmailFromCAS(CASid):
|
||||
return ""
|
||||
return CASid + "@ola.com"
|
||||
|
Reference in New Issue
Block a user