Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
UserMixin, RoleMixin, login_required
from runestone import db, app
# Define models
class Role(db.Document, RoleMixin):
name = db.StringField(max_length=80, unique=True)
description = db.StringField(max_length=255)
class User(db.Document, UserMixin):
email = db.StringField(max_length=255)
password = db.StringField(max_length=255)
active = db.BooleanField(default=True)
confirmed_at = db.DateTimeField()
course = db.StringField(max_length=50)
roles = db.ListField(db.ReferenceField(Role), default=[])
from runestone import db, app
# Define models
class Role(db.Document, RoleMixin):
name = db.StringField(max_length=80, unique=True)
description = db.StringField(max_length=255)
class User(db.Document, UserMixin):
email = db.StringField(max_length=255)
password = db.StringField(max_length=255)
active = db.BooleanField(default=True)
confirmed_at = db.DateTimeField()
course = db.StringField(max_length=50)
roles = db.ListField(db.ReferenceField(Role), default=[])
from flask.ext.mongoengine import MongoEngine
from flask.ext.security import Security, MongoEngineUserDatastore, \
UserMixin, RoleMixin, login_required
from runestone import db, app
# Define models
class Role(db.Document, RoleMixin):
name = db.StringField(max_length=80, unique=True)
description = db.StringField(max_length=255)
class User(db.Document, UserMixin):
email = db.StringField(max_length=255)
password = db.StringField(max_length=255)
active = db.BooleanField(default=True)
confirmed_at = db.DateTimeField()
course = db.StringField(max_length=50)
roles = db.ListField(db.ReferenceField(Role), default=[])
from flask import Flask, Blueprint, render_template, request
from flask.ext.security import Security, MongoEngineUserDatastore, \
UserMixin, RoleMixin, login_required
auth = Blueprint('auth', __name__,
template_folder='templates',static_folder='static')
from runestone import db, app
from runestone.model import *
from flask.ext.cors import cross_origin
# Setup Flask-Security
user_datastore = MongoEngineUserDatastore(db, User, Role)
# Create custom registration form here then add it on the constructor
# or maybe set it later with security.state.register_form
security = Security(app, user_datastore)
# Create a user to test with
@app.before_first_request
def create_user():
user_datastore.create_user(email='matt@nobien.net', password='password')
# Views
@auth.route('/authtest')
@login_required
@cross_origin(supports_credentials=True)
from flask.ext.security import Security, MongoEngineUserDatastore, \
UserMixin, RoleMixin, login_required
from runestone import db, app
# Define models
class Role(db.Document, RoleMixin):
name = db.StringField(max_length=80, unique=True)
description = db.StringField(max_length=255)
class User(db.Document, UserMixin):
email = db.StringField(max_length=255)
password = db.StringField(max_length=255)
active = db.BooleanField(default=True)
confirmed_at = db.DateTimeField()
course = db.StringField(max_length=50)
roles = db.ListField(db.ReferenceField(Role), default=[])
from flask.ext.mongoengine import MongoEngine
from flask.ext.security import Security, MongoEngineUserDatastore, \
UserMixin, RoleMixin, login_required
from runestone import db, app
# Define models
class Role(db.Document, RoleMixin):
name = db.StringField(max_length=80, unique=True)
description = db.StringField(max_length=255)
class User(db.Document, UserMixin):
email = db.StringField(max_length=255)
password = db.StringField(max_length=255)
active = db.BooleanField(default=True)
confirmed_at = db.DateTimeField()
course = db.StringField(max_length=50)
roles = db.ListField(db.ReferenceField(Role), default=[])