# Path: app/accounts/permissions.py
# def on_identity_loaded(sender, identity):


import datetime
from flask import render_template, redirect, request, flash, url_for, current_app, session, abort
from flask.views import MethodView
from flask_login import login_user, logout_user, login_required, current_user
from flask_principal import Identity, AnonymousIdentity, identity_changed
from . import models, forms, misc
from .permissions import admin_permission, su_permission
from OctBlog.config import OctBlogSettings
            user.is_superuser = True
        user.save()

        return redirect(url_for('main.index'))

    return render_template('accounts/registration.html', form=form)

@login_required
def add_user():
    form = forms.RegistrationForm()
    if form.validate_on_submit():
        user = models.User()
        user.username = form.username.data
        user.password = form.password.data
        user.email = form.email.data

        user.display_name = user.username

        user.save()

        return redirect(url_for('accounts.users'))

    return render_template('accounts/registration.html', form=form)

def get_current_user():
    user = models.User.objects.get(username=current_user.username)
    return user


class Users(MethodView):

# Path: app/accounts/permissions.py
# def on_identity_loaded(sender, identity):


# Path: app/accounts/views.py
import datetime
from flask import render_template, redirect, request, flash, url_for, current_app, session, abort
from flask.views import MethodView
from flask_login import login_user, logout_user, login_required, current_user
from flask_principal import Identity, AnonymousIdentity, identity_changed
from . import models, forms, misc
from .permissions import admin_permission, su_permission
from OctBlog.config import OctBlogSettings

            user.is_superuser = True
        user.save()

        return redirect(url_for('main.index'))

    return render_template('accounts/registration.html', form=form)

@login_required
def add_user():
    form = forms.RegistrationForm()
    if form.validate_on_submit():
        user = models.User()
        user.username = form.username.data
        user.password = form.password.data
        user.email = form.email.data

        user.display_name = user.username

        user.save()

        return redirect(url_for('accounts.users'))

    return render_template('accounts/registration.html', form=form)

def get_current_user():
    user = models.User.objects.get(username=current_user.username)
    return user


class Users(MethodView):

    decorators = [login_required, admin_permission.require(401)]