AbandonTech / abandonauth

An Authentic Auth Service...
GNU General Public License v3.0
4 stars 3 forks source link

Add Endpoint for Editing Developer Application Names #142

Open fisher60 opened 1 month ago

fisher60 commented 1 month ago

Summary

Developer application names should be editable, we should add a way to modify a developer application name. This could possibly be done with a generic patch endpoint for /developer_application. This endpoint will only be able to modify the name, in the future we may want to add additional fields that can be edited here.

ShubhamKalsekar commented 1 month ago

Implement the PATCH Endpoint:

from flask import Flask, request, jsonify

app = Flask(name)

Example data storage(Dummy Data) developer_applications = { 1: {'name': 'App One'}, 2: {'name': 'App Two'} }

@app.route('/developer_application/', methods=['PATCH']) #here Route Decorator and indicates a dynamic part of the URL, capturing the application ID def update_app_name(app_id): if app_id in developer_applications: data = request.get_json() if 'name' in data: developer_applications[app_id]['name'] = data['name'] return jsonify({'message': 'Application name updated successfully'}), 200 else: return jsonify({'error': 'No name provided'}), 400 else: return jsonify({'error': 'Application not found'}), 404

if name == 'main': app.run(debug=True)

reference: here

fisher60 commented 1 month ago

Thank you, this was overwhelmingly unhelpful and my day was made worse because of it.

ShubhamKalsekar commented 1 month ago

I am sorry for making your day worst but from my knowledge I already use in my project and it work And I am only suggesting you .And It upto you how to use it .

On Mon, 24 Jun, 2024, 9:15 pm Kyler, @.***> wrote:

Thank you, this was overwhelmingly unhelpful and my day was made worse because of it.

— Reply to this email directly, view it on GitHub https://github.com/AbandonTech/abandonauth/issues/142#issuecomment-2186881378, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWMNY7OKMQHWOV7RLQHUAQTZJA5LFAVCNFSM6AAAAABJUYF4GGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBWHA4DCMZXHA . You are receiving this because you commented.Message ID: @.***>

fisher60 commented 1 month ago

Hello, I originally assumed your comment was created by a bot/AI. My comment was mostly a joke as your comment was very irrelevant to this repo and this issue, so I did not suspect a real human was on the other end.

This project uses FastAPI, we do not use Flask, so your suggestion is not helpful. Furthermore, your suggestion appears to be closer to pseudo-code or perhaps an example to what an endpoint could look like in Flask.

We do not store our persistent data in a dictionary, so this suggestion is not relevant developer_applications[app_id]['name'] = data['name']. Instead, we write persistent data to a database, and it would be bad practice to maintain a dictionary like this. Your return message is also misleading/incorrect as nothing would be updated since the change would be discarded on application restart (since the dictionary is only stored in memory, the persistent developer_application would not be updated).

You also have multiple else statements on your if condition for error handling. This syntax is not correct, nor would the logic make sense as there is not check for the 404 response.

I do genuinely appreciate your contribution and attempt to help, though this comment was misguided and not actionable. If you would like to contribute to open-source, I would highly recommend simply creating a pull request with your proposed changes, we always appreciate that! Though, ensure that you are using the correct language and frameworks and following the repo guidelines.