当前位置: 首页>>代码示例>>Python>>正文


Python User.check_password方法代码示例

本文整理汇总了Python中models.User.check_password方法的典型用法代码示例。如果您正苦于以下问题:Python User.check_password方法的具体用法?Python User.check_password怎么用?Python User.check_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.User的用法示例。


在下文中一共展示了User.check_password方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestModels

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
class TestModels(unittest.TestCase):
    def setUp(self):
        User.objects.delete({'email':'[email protected]'})
        self.user = User(email='[email protected]', password='test')
        self.user.save()

        GPSDevice.objects.delete({'imei':'test'})
        self.device = GPSDevice(imei='test')
        self.device.save()

        self.user.devices.append(self.device)
        self.user.save()

    def tearDown(self):
        self.user.delete()
        self.device.delete()

    # User
    def test_user(self):
        assert(self.user.check_password('test'))

    # GPSDevice
    def test_device_user(self):
        assert(self.user==self.device.user)

    def test_unique_imei(self):
        try:
            d = GPSDevice(imei='test')
            d.save()
        except mongoengine.NotUniqueError, e:
            pass
        assert(mongoengine.NotUniqueError == type(e))
开发者ID:nukturnal,项目名称:gps-tracker-server,代码行数:34,代码来源:tests.py

示例2: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
    def post(self):

        user = User.check_password(request.form.get('username'), request.form.get('password'))
        if user:
            login_user(user)
            session['username'] = user.username
            return redirect(url_for('client.ClientAPIList'))
        else:
            flash(LoginMessages.LOGIN_ERROR, CssMessages.ERROR)
            return render_template('login.html')
开发者ID:fabiancabau,项目名称:clientmanager,代码行数:12,代码来源:login.py

示例3: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
def login():
    form = LoginForm(request.form)
    if form.validate():
        # since the form isn't bad, we check for valid user
        user = models.get_user(form.data['username'])
        if user != None and User.check_password(form.data['username'], form.data['password']):
            login_user(user)
            return redirect(request.args.get("next") or url_for("home"))
        else:
            return render_template("login.html", form=form, message="Username/password do not match.")
    return render_template("login.html", form=form, message=None)
开发者ID:MBloom,项目名称:OneDir,代码行数:13,代码来源:app.py

示例4: clean_password

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
    def clean_password(self):
        username = self.cleaned_data["username"]
        password = self.cleaned_data["password"]

        user_id = User.check_password(username, password)
        if not user_id:
            raise forms.ValidationError(_("Password or user are incorrect"))

        self.user_id = user_id

        return password
开发者ID:georgyturevich,项目名称:django_retwis,代码行数:13,代码来源:forms.py

示例5: test_hashed_password_is_not_plaintext

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
    def test_hashed_password_is_not_plaintext(self):
        """
        Check that the password is not plain text when we try to, for example, reset it.

        Check other aspects of changing User object's password
        """
        user = User("xXx_Supa_Saiyan_xXx", "password1", "[email protected]", False, False)
        user.password = "dogsname"
        self.assertNotEqual(user.password, "password1", "password not reset, password is plain text")
        self.assertNotEqual(user.password, generate_password_hash("password1"), "password not reset")
        self.assertNotEqual(user.password, "dogsname", "password is plain text")
        self.assertTrue(user.check_password("dogsname"), "password not changed successfully")
开发者ID:LoisWong,项目名称:info9117_flaskr,代码行数:14,代码来源:meterage_tests.py

示例6: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
    def post(self):
        email = self.request.get("email")
        password = self.request.get("password")
                    
        user = User.query(User.email == email).get()

        if User.check_password(original_password=password, user=user):
            self.createcookie(user=user)
            self.redirect_to("main")
            return
        else:
            return self.write("Napacno geslo ali email")
开发者ID:MihaGasper,项目名称:Bmail,代码行数:14,代码来源:main.py

示例7: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
    def post(self):
        ime = self.request.get("nickname")
        geslo = self.request.get("password")

        user = User.query(User.ime == ime).get()
        if user:
            check_user = User.check_password(user, geslo)

            if check_user:
                self.create_cookie(user=user)
                return self.redirect_to("hello")
            else:
                return self.write("Wrong password")
        else:
            return self.redirect_to("register")
开发者ID:MojcaFranic,项目名称:Bmail,代码行数:17,代码来源:main.py

示例8: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
def login():

    if request.method == "POST" and "username" in request.form:

        username = request.form["username"]
        password = request.form["password"]

        if User.check_password(username, password):

            remember = request.form.get("remember", "no") == "yes"

            if login_user(USER_NAMES[username], remember=remember):

                return redirect(request.args.get("next") or url_for("index"))

    return render_template("main.html")
开发者ID:daleobrien,项目名称:bootflask,代码行数:18,代码来源:main.py

示例9: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
def login():
    if current_user.is_authenticated:
        return redirect(url_for("index"))
    form = Login()
    if form.validate_on_submit():
        user = User.query.filter_by(name=form.name.data).first()
        if user is not None:
            if User.check_password(user, form.password.data):
                login_user(user, remember=True)
                logging.info("%s logged in" % user.name)
                response = make_response(redirect(url_for("index")))
                response.set_cookie('sse_channel_id', str(uuid.uuid4()))
                return response
        logging.warning("Invalid login")
        flash("Invalid username or password", "warning")
    return render_template("login.html", form=form)
开发者ID:siimsaar,项目名称:py-project,代码行数:18,代码来源:app.py

示例10: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
def login():
	if request.method == 'GET':
		form = LoginForm()
		return render_template('login.html',form = form)
	username = request.form['username']
	password = request.form['password']
	auth_user = User.query.filter_by(username=username).first()
	if auth_user is None:
		form = LoginForm()
		error = [u'Введите правильно имя пользователя или пароль',hash_pass]
		return render_template('login.html', form=form, error = error)
	if User.check_password(auth_user,password) is None:
		form = LoginForm()
		error = [u'Введите правильно имя пользователя или пароль',hash_pass]
		return render_template('login.html', form=form, error = error)

	login_user(auth_user)
	current_user = User.query.get(username)
	session['username'] = username
	#session['password'] = password
	session['loged_in'] = True
	#logened = User.is_authenticated()
	#return render_template('index.html',username = username, registered_user = registered_user, current_user = current_user)
	return redirect(url_for('index'))
开发者ID:ArioShaman,项目名称:flask-site,代码行数:26,代码来源:views.py

示例11: test_check_password

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
    def test_check_password(self):
        user = User.create_new('test', '11111')

        self.assertFalse(User.check_password('test', '22222'))
        self.assertEqual(str(user.id), User.check_password('test', '11111'))
开发者ID:georgyturevich,项目名称:django_retwis,代码行数:7,代码来源:tests.py

示例12: verify_password

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import check_password [as 别名]
def verify_password(username, password):
    return User.check_password(username, password)
开发者ID:MBloom,项目名称:OneDir,代码行数:4,代码来源:api.py


注:本文中的models.User.check_password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。