def do_POST(s): """Respond to a POST request.""" postvars = s.parse_POST() s.send_response(200) s.send_header("Content-type", "application/json") s.send_header("Cache-Control", "private, must-revalidate, max-age=0") s.send_header("Pragma", "no-cache") s.end_headers() if postvars.has_key("data") and postvars["data"][0]: data = json.loads(postvars["data"][0]) if not data: return t = user.User(data["user"]) if data.has_key("actionDeleteUser") and data["actionDeleteUser"]: user.deleteUser(data["user"]) return if data.has_key("actionModRatings") and data["actionModRatings"]: for i in data["modRatings"].keys(): t.modifyKeywordRating(i, data["modRatings"][i]) t.saveData() if data.has_key("actionGetRating") and data["actionGetRating"]: kws = termextract.getKeywords(data["text"]) data["keywords"] = kws data["rating"] = t.getRating(kws) s.wfile.write(json.dumps(data, indent=4))
def user_get_delete(user_id): if request.method == 'GET': list_res = [] try: list_res = getSpesificUser(user_id) except Exception as e: abort(400) return jsonify({'results': list_res}) elif request.method == 'DELETE': try: deleteUser(user_id) except Exception as e: abort(400) return jsonify({'results': 'DELETE'}), 200
def routeUser(username): if request.headers['Content-Type'] == 'application/json': if request.method == 'GET': return user.getUser(username) elif request.method == 'POST': return user.createUser(username, request.json) elif request.method == 'DELETE': return user.deleteUser(username) else: abort(415)
def deleteUser(): id = request.form.get('id') process = user.deleteUser(id) if process == 200: response = jsonify(message=True, code=200) response.status_code = 200 else: response = jsonify(message=False, code=500, data="Error occured. Please try again") response.status_code = 500 return response
def show_profile(request): ''' Displays the profile of the user that is currently logged in @pre user.is_authenticated() == True @post @author John Hartquist ''' #print 'in show_profile' #make sure user is logged in if request.user.is_authenticated(): #check if method was post if (request.method=="POST"): if (request.POST["form"] == "Change E-mail"): status = updateEmail(request) if status == 0: return master_rtr(request, 'user/profile.html', {'user': request.user}) else: return master_rtr(request, 'user/profile.html', {'user': request.user, 'emailError': "Invalid E-mail Address"}) if (request.POST["form"] == "Change Password"): status = changePassword(request) if status == 1: return master_rtr(request, 'user/profile.html', {'user': request.user, 'passError': "Incorrect current password"}) elif status == 2: return master_rtr(request, 'user/profile.html', {'user': request.user, 'passError': "Passwords do not match"}) if (request.POST["form"] == "Delete Account"): return master_rtr(request, 'user/confirmDelete.html') if (request.POST["form"] == "Update Name"): status = updateName(request) if status == 0: return master_rtr(request, 'user/profile.html', {'user': request.user, 'nameMessage':"Update Successful" }) if (request.POST["form"] == "Yes"): status = deleteUser(request) if status == 0: return HttpResponseRedirect(reverse('home.views.show_homepage')) return master_rtr(request, 'user/profile.html', {'user':request.user}) else: return master_rtr(request, 'user/notloggedin.html')
def delete_user(username, email): """ This function registers a new user with the specified email/password. :param email: The email to use for registration :param password: The password to use for the user :return: A redirect to a page that indicates success/failure as needed """ # first check recaptcha import requests user = deleteUser(username) #user = None if user is None: # TODO: Change this to an error page return json.dumps({'result': 'failed'}) else: session.clear() return json.dumps({'result': 'success'})
else: print("Input the message you want to encrypt:") msg = control.message_input() encrypted_msg = system_rsa.encrypt(msg) print('The encrypted message is: {}'.format( encrypted_msg)) elif control.input == 3: print("Input the encrypted message:") encrypted_msg = control.message_input() msg = system_rsa.decrypt(encrypted_msg) print('The decrypted message is: {}'.format(msg)) elif control.input == 4: user.displayUsers(users) elif control.input == 5: users = user.deleteUser(actual_user.get_username(), users) print('Deletion complete') actual_user = None break else: actual_user = None break elif control.input == 2: actual_user = user.User() actual_user.set_user(users) users.append(actual_user) else: print('Do you wish o ENCRYPT and SAVE the system settings?') print('Input:') print(' 1. Yes')
############################################################################################### ##Login LogIn = logIn(settings.GDHostname,settings.GDAdmin_username , settings.GDAdmin_password) GDCAuthSST = LogIn['GDCAuthSST'] #Get SST adminid = LogIn['Profile'] #Get Profile of loged user GDCAuthTT= getTT(settings.GDHostname,GDCAuthSST) #set Variable GDCAuthTT GetDomainUsers=getUsers(settings.GDHostname,GDCAuthTT,settings.GDDomain) json_acceptable_string = GetDomainUsers['read'].replace("'", "\"") d = json.loads(json_acceptable_string) iterace = d['accountSettings']['items'] user=createUser(settings.GDHostname,GDCAuthTT,settings.GDDomain,"*****@*****.**","*****@*****.**","Heslo123","TestJmeno","TestPrijmeni","") print user['code'] print user['read'] deletedUser=deleteUser(settings.GDHostname,GDCAuthTT,"/gdc/account/profile/589124c2f127f09fe803a22ceb66cf2e") print deletedUser['code'] print deletedUser['read'] #for item in iterace: # ChangePasswdUser(settings.GDHostname,GDCAuthTT,item['accountSetting']['links']['self'],item['accountSetting']['firstName'],item['accountSetting']['lastName'],adminid,"SecretPassword") #logOut(settings.GDHostname,GDCAuthTT,adminid)