Esempio n. 1
0
def create(username, password, firstname, lastname):
    if not validate_password(password):
        return api.error_401("Invalid password.")

    user = User.query.filter_by(username=username)
    if user.count():
        return api.error_403("This username already exists.")

    ts = datetime.datetime(1970, 1, 1)
    password_salt = generate_salt()
    password_hash = hash_password(password.encode("utf-8"), password_salt)

    try:
        new_user = User(username, firstname, lastname, password_hash,
                        password_salt, ts)
        db.session.add(new_user)
        db.session.commit()

    except Exception as e:
        return Response(utils.get_traceback(e),
                        status=500,
                        mimetype="text/plain")

    return Response(json.dumps({
        "message": "Account created successfully",
        "user_id": new_user.user_id,
        "username": username,
        "firstname": firstname,
        "lastname": lastname
    }),
                    mimetype="application/json")
Esempio n. 2
0
def get_traceback():
	"""Returns error traceback."""
	import utils
	return utils.get_traceback()
Esempio n. 3
0
def get_traceback():
	"""Returns error traceback."""
	import utils
	return utils.get_traceback()
Esempio n. 4
0
def get_traceback():
	import utils
	return utils.get_traceback()
Esempio n. 5
0
def get_traceback():
    import utils
    return utils.get_traceback()