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 imp
|
||||
|
||||
|
@ -18,18 +19,24 @@ def register():
|
|||
if request.method == 'POST':
|
||||
username = request.form['username']
|
||||
password = request.form['password']
|
||||
mail = request.form['email']
|
||||
error = None
|
||||
|
||||
#@TODO check if this really is an email.
|
||||
if not username:
|
||||
error = 'Username is required.'
|
||||
elif not password:
|
||||
error = 'Password is required.'
|
||||
elif not mail:
|
||||
error = 'Please enter your email adress'
|
||||
elif dbsession.query(User).filter(User.username == username).first() != None:
|
||||
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:
|
||||
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.commit()
|
||||
dbsession.close()
|
||||
|
|
|
@ -24,10 +24,8 @@ class User(Base):
|
|||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
username = Column(String(64))
|
||||
password = Column(String(64))
|
||||
# email = Column(String)
|
||||
# config
|
||||
# deck_size = Column(Integer)
|
||||
|
||||
email = Column(Text)
|
||||
settings = Column(Text) #neki json...
|
||||
|
||||
class Card(Base):
|
||||
__tablename__ = 'card'
|
||||
|
|
|
@ -30,6 +30,7 @@ def get_matches(user_id):
|
|||
|
||||
@bp.route("/", methods=("GET", "POST"))
|
||||
def index():
|
||||
#@TODO its buggs, not symetrical for users, shouldnt show if only you said yes
|
||||
if not 'user_id' in session:
|
||||
redirect(url_for('index'))
|
||||
|
||||
|
@ -40,7 +41,6 @@ def index():
|
|||
|
||||
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
|
||||
user_ids = []
|
||||
for match in list_of_matches:
|
||||
|
@ -52,6 +52,6 @@ def index():
|
|||
|
||||
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>
|
||||
<label for="password">Password</label>
|
||||
<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">
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -18,7 +18,7 @@
|
|||
<button type="submit" name="rate" value="No" accesskey="3">No</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>
|
||||
</article>
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
{% block header %}
|
||||
<head>Matches</head>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if list_of_matches %}
|
||||
<table>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if list_of_matches %}
|
||||
table>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Users</th>
|
||||
|
|
Loading…
Reference in New Issue