Exemplo n.º 1
0
 def api_admin_delete_user(self):
   mandatory = ['user']
   validator = Toolkit.requestValidation(request, Advanced_API.getAuth()[1] )
   if not validator.check_is_master(): return validator.error
   if  validator.check_if_json():
       if not validator.check_attributes(mandatory):
           return validator.error
       if  validator.check_object_exists("userExists", validator.content['user']):
               db.deleteUser(validator.content['user'])
               return make_response(jsonify(message="User {} deleted".format(validator.content['user'])))
   return validator.error
Exemplo n.º 2
0
 def api_admin_delete_user(self):
     content = request.get_json()
     if content:
         if 'user' not in content.keys():
             message, code = 'user is not defined', 200
         else:
             if not db.getUser(content['user']):
                 message, code = 'User {} not exists'.format(
                     content['user']), 200
             else:
                 db.deleteUser(content['user'])
                 message, code = "User {} deleted".format(
                     content['user']), 200
     return make_response(jsonify(message=message), code)
Exemplo n.º 3
0
         password = promptNewPass()
         dbLayer.addUser(username, password, admin=True)
     sys.exit("User added")
 elif args.c:
     username = args.c
     verifyPass(getpass.getpass("Old password:"******"Password updated")
 elif args.r:
     username = args.r
     if not dbLayer.userExists(username):
         sys.exit(exits['userNotInDb'])
     masterLogin()
     isLastAdmin(username)
     dbLayer.deleteUser(username)
     sys.exit('User removed from database')
 elif args.p:
     username = args.p
     if not dbLayer.userExists(username):
         sys.exit(exits['userNotInDb'])
     masterLogin()
     # promote
     dbLayer.setAdmin(username, True)
     sys.exit('User promoted')
 elif args.d:
     username = args.d
     if not dbLayer.userExists(username):
         sys.exit(exits['userNotInDb'])
     masterLogin()
     isLastAdmin(username)
         password = promptNewPass()
         dbLayer.addUser(username, password, admin=True)
     sys.exit("User added")
 elif args.c:
     username = args.c
     verifyPass(getpass.getpass("Old password:"******"Password updated")
 elif args.r:
     username = args.r
     if not dbLayer.userExists(username):
         sys.exit(exits['userNotInDb'])
     masterLogin()
     isLastAdmin(username)
     dbLayer.deleteUser(username)
     sys.exit('User removed from database')
 elif args.p:
     username = args.p
     if not dbLayer.userExists(username):
         sys.exit(exits['userNotInDb'])
     masterLogin()
     # promote
     dbLayer.setAdmin(username, True)
     sys.exit('User promoted')
 elif args.d:
     username = args.d
     if not dbLayer.userExists(username):
         sys.exit(exits['userNotInDb'])
     masterLogin()
     isLastAdmin(username)