Compare commits
6 Commits
f837501f10
...
64e0c7740d
Author | SHA1 | Date |
---|---|---|
Kostanjevec | 64e0c7740d | |
Kostanjevec | 4be9665006 | |
Kostanjevec | ba20635544 | |
Kostanjevec | 4f299ea07f | |
Kostanjevec | cb8492f3ec | |
Kostanjevec | 298fc96624 |
9
auth.py
9
auth.py
|
@ -1,3 +1,4 @@
|
||||||
|
import email
|
||||||
import functools
|
import functools
|
||||||
import imp
|
import imp
|
||||||
|
|
||||||
|
@ -18,18 +19,24 @@ def register():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
username = request.form['username']
|
username = request.form['username']
|
||||||
password = request.form['password']
|
password = request.form['password']
|
||||||
|
mail = request.form['email']
|
||||||
error = None
|
error = None
|
||||||
|
|
||||||
|
#@TODO check if this really is an email.
|
||||||
if not username:
|
if not username:
|
||||||
error = 'Username is required.'
|
error = 'Username is required.'
|
||||||
elif not password:
|
elif not password:
|
||||||
error = 'Password is required.'
|
error = 'Password is required.'
|
||||||
|
elif not mail:
|
||||||
|
error = 'Please enter your email adress'
|
||||||
elif dbsession.query(User).filter(User.username == username).first() != None:
|
elif dbsession.query(User).filter(User.username == username).first() != None:
|
||||||
error = "Username already exists, please choose another one"
|
error = "Username already exists, please choose another one"
|
||||||
|
elif dbsession.query(User).filter(User.email == mail).first() != None:
|
||||||
|
error = "This email adress is already in use, please choose another one"
|
||||||
|
|
||||||
if error is None:
|
if error is None:
|
||||||
try:
|
try:
|
||||||
user = User(username=username, password=md5(password.encode("utf-8")).hexdigest())
|
user = User(username=username, password=md5(password.encode("utf-8")).hexdigest(), email=mail, settings = "")
|
||||||
dbsession.add(user)
|
dbsession.add(user)
|
||||||
dbsession.commit()
|
dbsession.commit()
|
||||||
dbsession.close()
|
dbsession.close()
|
||||||
|
|
|
@ -24,10 +24,8 @@ class User(Base):
|
||||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
username = Column(String(64))
|
username = Column(String(64))
|
||||||
password = Column(String(64))
|
password = Column(String(64))
|
||||||
# email = Column(String)
|
email = Column(Text)
|
||||||
# config
|
settings = Column(Text) #neki json...
|
||||||
# deck_size = Column(Integer)
|
|
||||||
|
|
||||||
|
|
||||||
class Card(Base):
|
class Card(Base):
|
||||||
__tablename__ = 'card'
|
__tablename__ = 'card'
|
||||||
|
|
|
@ -30,6 +30,7 @@ def get_matches(user_id):
|
||||||
|
|
||||||
@bp.route("/", methods=("GET", "POST"))
|
@bp.route("/", methods=("GET", "POST"))
|
||||||
def index():
|
def index():
|
||||||
|
#@TODO its buggs, not symetrical for users, shouldnt show if only you said yes
|
||||||
if not 'user_id' in session:
|
if not 'user_id' in session:
|
||||||
redirect(url_for('index'))
|
redirect(url_for('index'))
|
||||||
|
|
||||||
|
@ -40,7 +41,6 @@ def index():
|
||||||
|
|
||||||
list_of_matches = get_matches(user_id)
|
list_of_matches = get_matches(user_id)
|
||||||
|
|
||||||
#@TODO tu bi morali dodati še nek users object, da own_id pretvorimo v username
|
|
||||||
#relevant userids, but might be uselessly duplicated
|
#relevant userids, but might be uselessly duplicated
|
||||||
user_ids = []
|
user_ids = []
|
||||||
for match in list_of_matches:
|
for match in list_of_matches:
|
||||||
|
@ -52,6 +52,6 @@ def index():
|
||||||
|
|
||||||
for id in user_ids:
|
for id in user_ids:
|
||||||
|
|
||||||
names_by_ids[id] = users.get(id).username
|
names_by_ids[id] = users.get(id).username
|
||||||
|
|
||||||
return render_template("matches.html", username=username, list_of_matches=list_of_matches, names_by_ids=names_by_ids)
|
return render_template("matches.html", username=username, list_of_matches=list_of_matches, names_by_ids=names_by_ids, users=users)
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
<input name="username" id="username" required>
|
<input name="username" id="username" required>
|
||||||
<label for="password">Password</label>
|
<label for="password">Password</label>
|
||||||
<input type="password" name="password" id="password" required>
|
<input type="password" name="password" id="password" required>
|
||||||
|
<label for="email">Email</label>
|
||||||
|
<input type="email" name="email" id="email" required>
|
||||||
<input type="submit" value="Register">
|
<input type="submit" value="Register">
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -18,7 +18,7 @@
|
||||||
<button type="submit" name="rate" value="No" accesskey="3">No</button>
|
<button type="submit" name="rate" value="No" accesskey="3">No</button>
|
||||||
<button type="submit" name="rate" value="Delete" accesskey="d">Delete</button>
|
<button type="submit" name="rate" value="Delete" accesskey="d">Delete</button>
|
||||||
|
|
||||||
<button style="margin-top: 1rem" type="submit" name="share" value="share">Share</button>
|
<button style="margin-top: 1rem" type="submit" name="share" value="share" accesskey="s">Share</button>
|
||||||
</form>
|
</form>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<head>Matches</head>
|
<head>Matches</head>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if list_of_matches %}
|
{% if list_of_matches %}
|
||||||
<table>
|
table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
<th>Users</th>
|
<th>Users</th>
|
||||||
|
|
Loading…
Reference in New Issue