Skip to content

How to created users with default roles ? #517

Closed Answered by jwag956
dvrg asked this question in Q&A
Discussion options

You must be logged in to vote

Attach to the user_registered signal, and add the role there:

@user_registered.connect_via(app)
def user_registered_sighandler(sender, **extra):
    # Add additional fields to new user - basic role
    logging.getLogger(__name__).debug("register handler: %s", extra)
    user = extra.get("user")
    sender.db.add_role_to_user(user, "basic")
    sender.db.commit()

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dvrg
Comment options

@jwag956
Comment options

Answer selected by dvrg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants