Move back user group into views.
This commit is contained in:
parent
a0fa75a26d
commit
8ec99a2cec
@ -15,8 +15,6 @@
|
||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
# vim: set tw=80 ts=4 sw=4 sts=4:
|
||||
import click
|
||||
|
||||
from passlib.hash import sha256_crypt as crypt
|
||||
from itsdangerous import (URLSafeTimedSerializer as Serializer,
|
||||
BadSignature, SignatureExpired)
|
||||
@ -28,25 +26,6 @@ from flask_login import UserMixin
|
||||
from accountant import db
|
||||
|
||||
|
||||
# Define commands to handle users.
|
||||
@app.cli.group()
|
||||
def user():
|
||||
""" User management. """
|
||||
pass
|
||||
|
||||
|
||||
@user.command()
|
||||
def add(email, password):
|
||||
""" Add a new user. """
|
||||
user = User()
|
||||
user.email = email
|
||||
user.password = User.hash_password(password)
|
||||
|
||||
db.session.add(user)
|
||||
|
||||
click.echo("User '%s' successfully added." % email)
|
||||
|
||||
|
||||
class User(UserMixin, db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
email = db.Column(db.String(200), nullable=False, unique=True, index=True)
|
||||
|
@ -15,6 +15,8 @@
|
||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
# vim: set tw=80 ts=4 sw=4 sts=4:
|
||||
import click
|
||||
|
||||
import arrow
|
||||
|
||||
from functools import wraps
|
||||
@ -30,6 +32,27 @@ from ..models.users import User
|
||||
|
||||
from .models import user_model, token_model, login_model
|
||||
|
||||
from accountant import db
|
||||
|
||||
|
||||
# Define commands to handle users.
|
||||
@app.cli.group()
|
||||
def user():
|
||||
""" User management. """
|
||||
pass
|
||||
|
||||
|
||||
@user.command()
|
||||
def add(email, password):
|
||||
""" Add a new user. """
|
||||
user = User()
|
||||
user.email = email
|
||||
user.password = User.hash_password(password)
|
||||
|
||||
db.session.add(user)
|
||||
|
||||
click.echo("User '%s' successfully added." % email)
|
||||
|
||||
|
||||
def load_user_from_token(token):
|
||||
return User.verify_auth_token(token)
|
||||
|
Loading…
Reference in New Issue
Block a user