diff --git a/servicePoints/views/__pycache__/accounts.cpython-36.pyc b/servicePoints/views/__pycache__/accounts.cpython-36.pyc index 242555ca6dea79a6e43a25c9c027d5ba21f10fe6..5fba22d061eb399d26ed5f24624065c794a7dfca 100644 Binary files a/servicePoints/views/__pycache__/accounts.cpython-36.pyc and b/servicePoints/views/__pycache__/accounts.cpython-36.pyc differ diff --git a/servicePoints/views/accounts.py b/servicePoints/views/accounts.py index 45154adeb4388b218c920cd3ffd3a7b2f391db22..b3960bc44f2ca1eae716792aa5d88c15fc47144d 100644 --- a/servicePoints/views/accounts.py +++ b/servicePoints/views/accounts.py @@ -1,4 +1,5 @@ import hashlib +import uuid import os import flask from flask import render_template @@ -73,11 +74,10 @@ def create(): if flask.session['password'] == '': flask.abort(400) - - # pw = hash_pass(flask.session['password']) + pw = hash_pass(flask.session['password']) data = (flask.session['username'], flask.session['fullname'], flask.session['email'], flask.session['orgName'], - flask.session['password']) + pw) cur = servicePoints.model.get_db() cur.execute("INSERT INTO users(username, fullname, email, orgName, " "password) VALUES (?, ?, ?, ?, ?)", data) @@ -93,4 +93,15 @@ def index(): if 'username' in flask.session: context = {} return render_template('index.html', **context) - return flask.redirect(flask.url_for('login')) \ No newline at end of file + return flask.redirect(flask.url_for('login')) + +def hash_pass(password_in): + """Hash passwords.""" + algorithm = 'sha512' + salt = uuid.uuid4().hex + hash_obj = hashlib.new(algorithm) + password_salted = salt + password_in + hash_obj.update(password_salted.encode('utf-8')) + password_hash = hash_obj.hexdigest() + password_db_string = "$".join([algorithm, salt, password_hash]) + return password_db_string diff --git a/var/servicePoints.sqlite3 b/var/servicePoints.sqlite3 index bff9d49cf56fd47864011e5adf386daed54d4018..8c0b335ad8cf3043d2bba7171a82254b229827b0 100644 Binary files a/var/servicePoints.sqlite3 and b/var/servicePoints.sqlite3 differ