diff --git a/user_managment/app.py b/user_managment/app.py index 1c1d656..46e5586 100644 --- a/user_managment/app.py +++ b/user_managment/app.py @@ -57,9 +57,9 @@ def convert_nato(string): 'M': 'MIKE', 'N': 'NOVEMBER','O': 'OSCAR', 'P': 'PAPA', 'Q': 'QUEBEC', 'R': 'ROMEO', 'S': 'SIERRA', 'T': 'TANGO', 'U': 'UNIFORM', 'V': 'VICTOR', 'W': 'WHISKEY', 'X': 'X-RAY', - 'Y': 'YANKEE', 'Z': 'ZULU', '0': 'zero', '1': 'one', - '2': 'two', '3': 'three', '4': 'four', '5': 'five', - '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine', + 'Y': 'YANKEE', 'Z': 'ZULU', '0': 'zero(0)', '1': 'one(1)', + '2': 'two(2)', '3': 'three(3)', '4': 'four(4)', '5': 'five(5)', + '6': 'six(6)', '7': 'seven(7)', '8': 'eight(8)', '9': 'nine(9)', 'a': 'alpha', 'b': 'bravo', 'c': 'charlie', 'd': 'delta', 'e': 'echo', 'f': 'foxtrot', 'g': 'golf', 'h': 'hotel', 'i': 'india', 'j': 'juliett','k': 'kilo', 'l': 'lima', @@ -207,7 +207,7 @@ def create_app(): ##

Sign out

## {% endblock %} ## """) - return render_template('index.html', markup_content = content, logo = logo) + return render_template('index.html', markup_content = content) @app.route('/generate_passphrase/pi-star', methods = ['GET']) @login_required @@ -257,7 +257,7 @@ def create_app(): #return str(content) - return render_template('flask_user_layout.html', markup_content = Markup(content), logo = logo) + return render_template('flask_user_layout.html', markup_content = Markup(content)) @@ -280,7 +280,7 @@ def create_app(): if i[1] == '': link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8) script_links[i[0]] = link_num - print(script_links) + #print(script_links) content = content + '''\n @@ -335,7 +335,7 @@ def create_app(): #return str(content) - return render_template('view_passphrase.html', markup_content = Markup(content), logo = logo) + return render_template('view_passphrase.html', markup_content = Markup(content)) # The Members page is only accessible to authenticated users via the @login_required decorator @app.route('/members') @@ -354,7 +354,7 @@ def create_app(): ## {% endblock %} ## """) content = 'Mem only' - return render_template('flask_user_layout.html', markup_content = content, logo = logo) + return render_template('flask_user_layout.html', markup_content = content) # The Admin page requires an 'Admin' role. @@ -479,7 +479,7 @@ def create_app(): ## {% endblock %} ## """) - return render_template('flask_user_layout.html', markup_content = Markup(content), logo = logo) + return render_template('flask_user_layout.html', markup_content = Markup(content)) @app.route('/get_script') def get_script(): @@ -599,7 +599,7 @@ def create_app(): else: content = 'Created user ' + str(request.form.get('Error')) - return render_template('flask_user_layout.html', markup_content = Markup(content), logo = logo) + return render_template('flask_user_layout.html', markup_content = Markup(content)) @app.route('/auth', methods=['POST']) def auth(): diff --git a/user_managment/application.py b/user_managment/application.py deleted file mode 100644 index e536083..0000000 --- a/user_managment/application.py +++ /dev/null @@ -1,123 +0,0 @@ -from flask import Flask, render_template, request, Response, Markup, jsonify, make_response -from config import * -import base64, hashlib -from dmr_utils3.utils import int_id, bytes_4 - -auth_dict = {} - - - -app = Flask(__name__) - -def gen_passphrase(dmr_id): - _new_peer_id = bytes_4(int(str(dmr_id)[:7])) - calc_passphrase = base64.b64encode((_new_peer_id) + append_int.to_bytes(2, 'big')) - return str(calc_passphrase)[2:-1] - - -@app.route('/gen', methods = ['POST', 'GET']) -def gen(): - #content = Markup('The HTML String') - user_id = request.args.get('user_id') - print(user_id) - print(request.args.get('mode')) - if request.args.get('mode') == 'generated': - auth_dict.update({int(user_id):''}) - content = ''' -

Your passphrase for ''' + str(user_id) + ''':

-

''' + str(gen_passphrase(int(user_id))) + '''

-''' - if request.args.get('mode') == 'legacy': - auth_dict.update({int(user_id):0}) - content = '''

Using legacy auth

''' - if request.args.get('mode') == 'custom': - auth_dict.update({int(user_id):str(request.args.get('custom'))}) - content = '''

Using custom auth passphrase: ''' + request.args.get('custom') + '''

''' - - print(auth_dict) - - - return render_template('generic.html', title = title, url = url, logo = logo, content = Markup(content)) - - - -@app.route('/') -def index(): - #content = Markup('The HTML String') - content = ''' -
- - - - - -
- - - - - - - - - - - - - - - - - - -
-

-
Custom Password (only use if custom is selected):
-
-

 

-''' - - - return render_template('generic.html', title = title, url = url, logo = logo, content = Markup(content)) - -@app.route('/auth', methods=['POST']) -def auth(): - hblink_req = request.json - print((hblink_req)) - print(auth_dict) - if hblink_req['secret'] in shared_secrets: - if hblink_req['id'] in auth_dict: - if auth_dict[hblink_req['id']] == 0: - response = jsonify( - allow=True, - mode='legacy', - ) - elif auth_dict[hblink_req['id']] == '': - # normal - response = jsonify( - allow=True, - mode='normal', - ) - elif auth_dict[hblink_req['id']] != '' or auth_dict[hblink_req['id']] != 0: - response = jsonify( - allow=True, - mode='override', - value=auth_dict[hblink_req['id']] - ) - if hblink_req['id'] not in auth_dict: - response = jsonify( - allow=False) - else: - message = jsonify(message='Authentication error') - response = make_response(message, 401) - - return response - - -if __name__ == '__main__': - - app.run(debug = True, port=ums_port, host=ums_host) diff --git a/user_managment/config-SAMPLE.py b/user_managment/config-SAMPLE.py index ab1cfa7..14fdcac 100644 --- a/user_managment/config-SAMPLE.py +++ b/user_managment/config-SAMPLE.py @@ -13,8 +13,6 @@ use_short_passphrase = False # Title of the Dashboard title = 'MMDVM User Portal' -# Logo used on dashboard page -logo = 'https://github.com/HBLink-org/hblink3/raw/master/HBlink.png' # Port to run server ums_port = 8080 # IP to run server on diff --git a/user_managment/static/HBlink.png b/user_managment/static/HBlink.png new file mode 100644 index 0000000..29fa556 Binary files /dev/null and b/user_managment/static/HBlink.png differ diff --git a/user_managment/templates/flask_user_layout.html b/user_managment/templates/flask_user_layout.html index 052ae00..e84ec1f 100644 --- a/user_managment/templates/flask_user_layout.html +++ b/user_managment/templates/flask_user_layout.html @@ -31,7 +31,7 @@

{{ user_manager.USER_APP_NAME }}

-

Logo

+

Logo

{{title}}


diff --git a/user_managment/templates/footer.html b/user_managment/templates/footer.html deleted file mode 100644 index ca7475b..0000000 --- a/user_managment/templates/footer.html +++ /dev/null @@ -1,5 +0,0 @@ -
-
-
{{title}} created by KF7EEL, W7NCX, and N9VW.
pnwdigital.net
- - diff --git a/user_managment/templates/generic.html b/user_managment/templates/generic.html deleted file mode 100644 index 6e5b22c..0000000 --- a/user_managment/templates/generic.html +++ /dev/null @@ -1,5 +0,0 @@ -{% include 'page.html' %} -{% include 'header.html' %} -{{content}} -{% include 'footer.html' %} - diff --git a/user_managment/templates/header.html b/user_managment/templates/header.html deleted file mode 100644 index e3a4016..0000000 --- a/user_managment/templates/header.html +++ /dev/null @@ -1,11 +0,0 @@ -

Logo

-

{{title}}

-
-
- - - - - -
-
diff --git a/user_managment/templates/page.html b/user_managment/templates/page.html deleted file mode 100644 index 1c67ad4..0000000 --- a/user_managment/templates/page.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {{title}} - - -
-