def change_password(): """Change password endpoint""" print('change password', current_identity) data = request.get_json() if not current_identity.check_password(data['password']): return jsonify(errors={'password': '******'}), 401 elif data['newPassword'] != data['confirmPassword']: return jsonify(errors={'confirmPassword': '******'}), 401 current_identity.set_password(data['newPassword']) db.session.add(current_identity) db.session.commit() return jsonify(result='Password successfully changed')
def change_email(): """Change email endpoint""" print('change email', current_identity) data = request.get_json() if not current_identity.check_password(data['password']): return jsonify(errors={'password': '******'}), 401 elif User.query.filter_by(email=data['email']).first(): return jsonify(errors={'email': 'A User with that Email Address already exists'}),\ 409 current_identity.email = data['email'] db.session.add(current_identity) db.session.commit() return jsonify(result='Email successfully changed')
def change_email(): """Change email endpoint""" print('change email', current_identity) data = request.get_json() if not current_identity.check_password(data['password']): return jsonify(errors= {'password': '******'}), 401 elif User.query.filter_by(email=data['email']).first(): return jsonify(errors={'email': 'A User with that Email Address already exists'}),\ 409 current_identity.email = data['email'] db.session.add(current_identity) db.session.commit() return jsonify(result='Email successfully changed')
def change_password(): if request.mimetype != 'application/json': abort(415) data = register_schema(request.json) if not current_identity.check_password(data['current_password']): return jsonify( {'errors': { 'current_password': '******' }}), 400 current_identity.password = data['new_password'] db.session.commit() return jsonify({'success': 'User created'})