當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.encrypt_password方法代碼示例

本文整理匯總了Python中flask_security.utils.encrypt_password方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.encrypt_password方法的具體用法?Python utils.encrypt_password怎麽用?Python utils.encrypt_password使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask_security.utils的用法示例。


在下文中一共展示了utils.encrypt_password方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def create():
    '''Create a new user'''
    data = {
        'first_name': click.prompt('First name'),
        'last_name': click.prompt('Last name'),
        'email': click.prompt('Email'),
        'password': click.prompt('Password', hide_input=True),
        'password_confirm': click.prompt('Confirm Password', hide_input=True),
    }
    # Until https://github.com/mattupstate/flask-security/issues/672 is fixed
    with current_app.test_request_context():
        form = RegisterForm(MultiDict(data), meta={'csrf': False})
    if form.validate():
        data['password'] = encrypt_password(data['password'])
        del data['password_confirm']
        data['confirmed_at'] = datetime.utcnow()
        user = datastore.create_user(**data)
        success('User(id={u.id} email={u.email}) created'.format(u=user))
        return user
    errors = '\n'.join('\n'.join(e) for e in form.errors.values())
    exit_with_error('Error creating user', errors) 
開發者ID:opendatateam,項目名稱:udata,代碼行數:23,代碼來源:commands.py

示例2: user

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def user(self, role_names=None, organization=None):
        if role_names is None:
            role_names = []
        from psi.app.models import User, Role
        from flask_security.utils import encrypt_password
        user = User()
        user.active = True
        user.display = self.faker.name()
        user.email = self.faker.email()
        user.login = self.faker.name()
        password = self.faker.password()
        user.password = encrypt_password(password)
        if organization is None:
            user.organization = self.organization()
        else:
            user.organization = organization
        for role_name in role_names:
            role = Role.query.filter_by(name=role_name).first()
            user.roles.append(role)
        return user, password 
開發者ID:betterlife,項目名稱:betterlifepsi,代碼行數:22,代碼來源:object_faker.py

示例3: a_user

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def a_user(app, session, project_client, name, email,
           logged_in, disabled, active):
    """ gives us a user who is a member.
    """
    from pygameweb.user.models import User, Group
    from flask_security.utils import encrypt_password
    group = Group(name='members', title='Member')
    user = User(name=name,
                email=email,
                password=encrypt_password('password'),
                disabled=disabled,
                active=active,
                roles=[group])
    session.add(user)
    session.commit()

    # https://flask-login.readthedocs.org/en/latest/#fresh-logins
    with project_client.session_transaction() as sess:
        sess['user_id'] = user.id
        sess['_fresh'] = True
    return user 
開發者ID:pygame,項目名稱:pygameweb,代碼行數:23,代碼來源:test_project_views.py

示例4: user

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def user(app, session, wiki_client):
    """ gives us a user who is a member.
    """
    from pygameweb.user.models import User
    from flask_security.utils import encrypt_password
    user = User(name='joe',
                email='asdf@example.com',
                password=encrypt_password('password'))
    session.add(user)
    session.commit()
    # https://flask-login.readthedocs.org/en/latest/#fresh-logins
    with wiki_client.session_transaction() as sess:
        sess['user_id'] = user.id
        sess['_fresh'] = True

    return user 
開發者ID:pygame,項目名稱:pygameweb,代碼行數:18,代碼來源:test_wiki_views.py

示例5: a_user

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def a_user(app, session, news_client, name, email,
           logged_in, disabled, active):
    """ gives us a user who is a member.
    """
    from pygameweb.user.models import User, Group
    from flask_security.utils import encrypt_password
    group = Group(name='admin', title='Admin')
    user = User(name=name,
                email=email,
                password=encrypt_password('password'),
                disabled=disabled,
                active=active,
                roles=[group])
    session.add(user)
    session.commit()

    # https://flask-login.readthedocs.org/en/latest/#fresh-logins
    with news_client.session_transaction() as sess:
        sess['user_id'] = user.id
        sess['_fresh'] = True
    return user 
開發者ID:pygame,項目名稱:pygameweb,代碼行數:23,代碼來源:test_news_views.py

示例6: user

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def user(app, session, comment_client):
    """ gives us a user who is a member.
    """
    from pygameweb.user.models import User
    from flask_security.utils import encrypt_password
    user = User(name='joe',
                email='asdf@example.com',
                password=encrypt_password('password'))
    session.add(user)
    session.commit()
    # https://flask-login.readthedocs.org/en/latest/#fresh-logins
    with comment_client.session_transaction() as sess:
        sess['user_id'] = user.id
        sess['_fresh'] = True

    return user 
開發者ID:pygame,項目名稱:pygameweb,代碼行數:18,代碼來源:test_comment.py

示例7: run

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def run(self, **kwargs):
        # handle confirmed
        if re.sub(r"\s", "", str(kwargs.pop("confirmed"))).lower() in [
            "",
            "y",
            "yes",
            "1",
            "active",
        ]:
            kwargs["confirmed_at"] = datetime.datetime.now()

        # sanitize active input
        ai = re.sub(r"\s", "", str(kwargs["active"]))
        kwargs["active"] = ai.lower() in ["", "y", "yes", "1", "active"]

        from flask_security.forms import ConfirmRegisterForm
        from werkzeug.datastructures import MultiDict

        form = ConfirmRegisterForm(MultiDict(kwargs), csrf_enabled=False)

        if form.validate():
            kwargs["password"] = encrypt_password(kwargs["password"])
            user_datastore.create_user(**kwargs)
            print("User created successfully.")
            kwargs["password"] = "****"
            pprint(kwargs)
        else:
            print("Error creating user")
            pprint(form.errors) 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:31,代碼來源:manage.py

示例8: password

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def password(email):
    user = datastore.get_user(email)
    password = click.prompt('Enter new password', hide_input=True)
    user.password = encrypt_password(password)
    user.save() 
開發者ID:opendatateam,項目名稱:udata,代碼行數:7,代碼來源:commands.py

示例9: on_model_change

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def on_model_change(self, form, model, is_created):

        # If the password field isn't blank...
        if len(model.password2):

            # ... then encrypt the new password prior to storing it in the database. If the password field is blank,
            # the existing password in the database will be retained.
            model.password = encrypt_password(model.password2) 
開發者ID:dynilib,項目名稱:submission,代碼行數:10,代碼來源:views.py

示例10: create_defaults

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def create_defaults(self):
        from . import Country
        from flask_security.utils import encrypt_password

        admin_user = User()
        admin_user.first_name = "Admin"
        admin_user.last_name = "Admin"
        admin_user.admin = True
        admin_user.email = "admin@code4sa.org"
        admin_user.country = Country.query.filter(Country.name == 'South Africa').one()
        admin_user.password = encrypt_password('admin')

        return [admin_user] 
開發者ID:Code4SA,項目名稱:mma-dexter,代碼行數:15,代碼來源:user.py

示例11: on_model_change

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def on_model_change(self, form, model, is_created):
        if not is_super_admin():
            super(UserAdmin, self).on_model_change(form, model, is_created)
        # If the password field isn't blank...
        if len(model.password2):
            # ... then encrypt the new password prior to storing it in the database. If the password field is blank,
            # the existing password in the database will be retained.
            model.password = encrypt_password(model.password2) 
開發者ID:betterlife,項目名稱:betterlifepsi,代碼行數:10,代碼來源:user.py

示例12: on_model_change

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def on_model_change(self, form, model, is_created):
        if len(model.password2):
            model.password = utils.encrypt_password(model.password2) 
開發者ID:pygame,項目名稱:pygameweb,代碼行數:5,代碼來源:views.py

示例13: create_test_models

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def create_test_models():
    user_datastore.create_user(email='test', password=encrypt_password('test'))
    user_datastore.create_user(email='test2', password=encrypt_password('test2'))
    stuff = SomeStuff(data1=2, data2='toto', user_id=1)
    db.session.add(stuff)
    stuff = SomeStuff(data1=5, data2='titi', user_id=1)
    db.session.add(stuff)
    db.session.commit() 
開發者ID:graup,項目名稱:flask-restless-security,代碼行數:10,代碼來源:server.py

示例14: setUp

# 需要導入模塊: from flask_security import utils [as 別名]
# 或者: from flask_security.utils import encrypt_password [as 別名]
def setUp(self):
        app.config.from_object('config.TestingConfig')
        self.client = app.test_client()

        db.init_app(app)
        with app.app_context():
            db.create_all()
            user_datastore.create_user(email='test', password=encrypt_password('test'))
            db.session.commit() 
開發者ID:graup,項目名稱:flask-restless-security,代碼行數:11,代碼來源:test.py


注:本文中的flask_security.utils.encrypt_password方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。