Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,14 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Run linter
run: uv run ruff check .

- name: Run format
run: uv run ruff format . --check

- name: Run type check
run: uv run mypy .

- name: Run tests
run: uv run pytest
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ To run tests with all supported Python versions:
$ uv run tox
```

## Linter, format & type check

```console
$ uv run ruff check . --fix
$ uv run ruff format .
$ uv run mypy .
```

## Docs

To build the docs, use [Sphinx](https://www.sphinx-doc.org/en/):
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# -- Project information -----------------------------------------------------

project = "Flask Simple Login"
copyright = "2020, Maely Brandão"
copyright = "2020, Maely Brandão" # noqa: A001
author = "Maely Brandão"


Expand Down Expand Up @@ -66,4 +66,4 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []
html_static_path: list[str] = []
20 changes: 13 additions & 7 deletions example/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@

import click
from flask import Flask, jsonify, render_template
from flask_simplelogin import Message, SimpleLogin, login_required
from werkzeug.security import check_password_hash, generate_password_hash

from flask_simplelogin import Message, SimpleLogin, login_required

# [ -- Utils -- ]


def validate_login(user):
db_users = json.load(open("users.json"))
with open("users.json") as handler:
db_users = json.load(handler)

if not db_users.get(user["username"]):
return False

stored_password = db_users[user["username"]]["password"]
if check_password_hash(stored_password, user["password"]):
return True
return False
return check_password_hash(stored_password, user["password"])


def create_user(**data):
Expand All @@ -33,11 +34,16 @@ def create_user(**data):

# Here you insert the `data` in your users database
# for this simple example we are recording in a json file
db_users = json.load(open("users.json"))
with open("users.json") as handler:
db_users = json.load(handler)

# add the new created user to json
db_users[data["username"]] = data

# commit changes to database
json.dump(db_users, open("users.json", "w"))
with open("users.json", "w") as handler:
json.dump(db_users, handler)

return data


Expand Down
1 change: 1 addition & 0 deletions example/simple_app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Flask, jsonify, render_template
from flask.views import MethodView

from flask_simplelogin import SimpleLogin, get_username, login_required

my_users = {
Expand Down
Loading