|
|
@@ -43,14 +43,30 @@ def auth_response():
|
|
|
code = request.args.get('code')
|
|
|
state = request.args.get('state')
|
|
|
if state == state_value: # Check that the state value returned matches the state value sent
|
|
|
- current_app.logger.info(f'Valid CSRF Code. Streamer authenticated.')
|
|
|
+ current_app.logger.info(f'CSRF code is valid.')
|
|
|
+ owncast_url = current_app.config['OWNCAST_URL']
|
|
|
+ owncast_auth_url = f'{owncast_url}/api/auth/provider/indieauth'
|
|
|
+ client_id = current_app.config['INDIEAUTH_CLIENT_ID']
|
|
|
+ client_secret = current_app.config['INDIEAUTH_CLIENT_SECRET']
|
|
|
+ # https://owncast.online/api/latest/#tag/Auth
|
|
|
+ # https://aaronparecki.com/2021/04/13/26/indieauth
|
|
|
+ token_response = requests.post(owncast_auth_url, data={
|
|
|
+ 'client_id': client_id,
|
|
|
+ 'client_secret': client_secret,
|
|
|
+ 'code': code,
|
|
|
+ 'redirect_uri': url_for("web_panels.auth_response", _external=True),
|
|
|
+ 'grant_type': 'authorization_code',
|
|
|
+ 'code_verifier': state
|
|
|
+ })
|
|
|
+
|
|
|
+ return_data = token_response.json()
|
|
|
+ f_return_data = json.dumps(return_data, indent=4)
|
|
|
+ auth_photo = return_data['profile']['photo']
|
|
|
+ session['user'] = f_return_data
|
|
|
|
|
|
- user_info = 'code'
|
|
|
-
|
|
|
- session['user'] = user_info
|
|
|
return redirect(url_for('web_panels.mgmt'))
|
|
|
else:
|
|
|
- current_app.logger.info(f'Invalid CSRF Code. Streamer not authenticated.')
|
|
|
+ current_app.logger.info(f'Invalid CSRF Code.')
|
|
|
return 'Not Authorized'
|
|
|
|
|
|
|
|
|
@@ -74,7 +90,6 @@ def mgmt():
|
|
|
active_categories = current_app.config['ACTIVE_CAT']
|
|
|
inactive_categories = current_app.config['INACTIVE_CAT']
|
|
|
all_cats = current_app.config['ALL_CAT']
|
|
|
- mgmt_auth = current_app.config['MGMT_AUTH']
|
|
|
points_interval = current_app.config['POINTS_INTERVAL']
|
|
|
points_award = current_app.config['POINTS_AWARD']
|
|
|
gunicorn_logging = current_app.config['GUNICORN']
|
|
|
@@ -87,7 +102,6 @@ def mgmt():
|
|
|
announce_interval = current_app.config['ANNOUNCE_INTERVAL']
|
|
|
announcements = current_app.config['ANNOUNCEMENTS']
|
|
|
settings_info = [
|
|
|
- mgmt_auth,
|
|
|
points_interval,
|
|
|
points_award,
|
|
|
gunicorn_logging,
|
|
|
@@ -281,11 +295,9 @@ def settings():
|
|
|
prefix = request.form['prefix']
|
|
|
access_token = request.form['access_token']
|
|
|
owncast_url = request.form['owncast_url']
|
|
|
- mgmt_auth = request.form['mgmt_auth']
|
|
|
kofi_integration = 'kofi_integration' in request.form
|
|
|
kofi_token = request.form['kofi_token']
|
|
|
config_dict = {
|
|
|
- 'MGMT_AUTH': mgmt_auth,
|
|
|
'POINTS_INTERVAL': points_interval,
|
|
|
'POINTS_AWARD': points_award,
|
|
|
'GUNICORN': gunicorn_logging,
|
|
|
@@ -315,7 +327,7 @@ def announcements():
|
|
|
}
|
|
|
if save_announce(announce_dict): # Save new announce.py
|
|
|
current_app.logger.info('Saved new announcements.')
|
|
|
-
|
|
|
+
|
|
|
return redirect(url_for('web_panels.mgmt'))
|
|
|
|
|
|
|
|
|
@@ -330,7 +342,7 @@ def ksettings():
|
|
|
sub_points = int(request.form['sub_points'])
|
|
|
kofi_url = request.form['kofi_url']
|
|
|
kofi_logo = request.form.get('kofi_logo')
|
|
|
-
|
|
|
+
|
|
|
kofi_settings_dict['donations'] = enable_donations
|
|
|
kofi_settings_dict['subs'] = enable_subs
|
|
|
kofi_settings_dict['sub_points'] = sub_points
|
|
|
@@ -338,7 +350,7 @@ def ksettings():
|
|
|
kofi_settings_dict['kofi_logo'] = kofi_logo
|
|
|
if save_kofi_settings(kofi_settings_dict):
|
|
|
current_app.logger.info(f'Saved Kofi settings')
|
|
|
-
|
|
|
+
|
|
|
return redirect(url_for('web_panels.mgmt'))
|
|
|
|
|
|
|
|
|
@@ -348,18 +360,18 @@ def add(reward_type):
|
|
|
all_cats = current_app.config['ALL_CAT']
|
|
|
active_categories = current_app.config['ACTIVE_CAT']
|
|
|
all_the_rewards = current_app.config['REWARDS']
|
|
|
-
|
|
|
+
|
|
|
if request.method == 'POST':
|
|
|
name = request.form['name']
|
|
|
name = name.lower() # Force the name to all lower case
|
|
|
name = emoji.demojize(name) # Remove any emojis
|
|
|
name = name.replace(" ", "") # Remove any spaces from the name
|
|
|
type = request.form['type']
|
|
|
-
|
|
|
+
|
|
|
if name in all_the_rewards: # Check for duplicate reward names
|
|
|
flash("A reward with this name already exists.", "error") # Flash an error message
|
|
|
return redirect(url_for('web_panels.add', reward_type=reward_type)) # Redirect back to the add page
|
|
|
-
|
|
|
+
|
|
|
if type != 'category': # If we're only adding a category, skip all of this
|
|
|
cooldown = int(request.form['cooldown'])
|
|
|
if type == 'redeem' or type == 'special' or type == 'vote':
|