Exemplo n.º 1
0
def password_salt():
	try:
		salt = session.query(ConfigOption.value).filter(ConfigOption.key=='password_salt').one().value
	except NoResultFound:
		salt = b64encode(os.urandom(16))
		co = ConfigOption('password_salt', salt)
		session.add(co)
	return salt
Exemplo n.º 2
0
def comment_create(request):
    c = Comment(
        request.form["title"],
        request.form["author_fullname"],
        request.form["author_email"],
        request.form["author_website"],
        datetime.datetime.now().isoformat(),
        request.form["content"],
    )
    session.add(c)
    session.commit()
    return render_json(c.to_api_dict())
Exemplo n.º 3
0
def create_user(request):
    try:
        u = session.query(User).filter(User.username == request.form["username"]).one()
        logging.debug("Not creating user %s, username already in use." % request.form["username"])
        return DuplicateError
    except NoResultFound:
        pass
    u = User(
        request.form["username"],
        request.form["fullname"],
        hash_password(request.form["password"]),
        request.form["editor"] == "true",
        request.form["superuser"] == "true",
    )
    # handle query errors and return a valid response
    session.add(u)
    session.commit()
    u = session.query(User).filter(User.username == request.form["username"]).one()
    return render_json(u.to_api_dict())
Exemplo n.º 4
0
def create_entry(request):
    e = Entry(request.form["title"], request.form["content"], request.user.id)
    session.add(e)
    session.commit()
    return render_json(e.to_api_dict())