1
0
forked from orson/bachemap

invite code fixed (but WHY)

This commit is contained in:
Orson 2024-09-12 16:56:41 -06:00
parent 849b5cbafc
commit ffcbaff534
3 changed files with 22 additions and 18 deletions

15
app.py
View File

@ -13,14 +13,15 @@ from wtforms.validators import DataRequired, Length
import requests
from config import Config
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="Bachemapa @ baches.qro.mx")
def create_app(config=Config):
app = Flask(__name__)
app.config.from_object(config)
mongo = PyMongo(app)
login_manager = LoginManager(app)
login_manager.login_view = 'thelogin'
login_manager.session_protection = "strong"
class User(UserMixin):
@ -209,13 +210,15 @@ def create_app(config=Config):
@app.route('/dashboard')
@login_required
def dashboard():
if request.method == 'GET':
if current_user.is_authenticated == False:
return redirect(url_for('thelogin'))
else:
#if request.method == 'GET':
#if current_user.is_authenticated == False:
# return redirect(url_for('thelogin'))
#else:
old_qr = mongo.db.users.find_one({'_id': ObjectId(current_user.id)})
print(old_qr)
invite_code = str(uuid4())
qr_update = mongo.db.users.update_one({'_id': ObjectId(current_user.id)}, {'$set': {'referral_code': invite_code}})
print(qr_update)
print(invite_code)
if not current_user.is_admin:
pins = list(mongo.db.pins.find({"added_by": current_user.id}))
return render_template('dashboard.html', pins=pins, invite_code=invite_code)

View File

@ -3,3 +3,4 @@ class Config:
UPLOAD_FOLDER = 'uploads'
SECRET_KEY = 'supersecretkey'
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
LOGIN_URL = '/thelogin'

View File

@ -15,7 +15,7 @@
</div>
<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrgen"), {
text: "https://baches.qro.mx/registrame/{{current_user.referral_code}}",
text: "https://baches.qro.mx/registrame/{{invite_code}}",
width: 256,
height: 256,
colorDark : "#000000",
@ -25,7 +25,7 @@
</script>
<div>
<h2>Tu link es:</h2>
<p><a href="https://baches.qro.mx/registrame/{{current_user.referral_code}}">https://baches.qro.mx/registrame/{{current_user.referral_code}}</a></p>
<p><a href="https://baches.qro.mx/registrame/{{invite_code}}">https://baches.qro.mx/registrame/{{invite_code}}</a></p>
</div>
</div>
{% if pins %}