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


Python User.password方法代碼示例

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


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

示例1: create_user

# 需要導入模塊: from database import User [as 別名]
# 或者: from database.User import password [as 別名]
def create_user(Session,username,password,public_key,creator):
	s=Session
	user=get_user(s,username)
	if user is None:
		if creator:
			cid=creator.id
		else:
			cid=None
		u=User(name=username,password=genpw(password),creator=cid,public_key=public_key)
		s.add(u)
		s.commit()
		return True
	else:
		u=user
		if not creator: return False
		if u.id==creator.id or creator.name=='admin':
			if not password is None:
				if password=='':
					u.password=''
				else:
					u.password=genpw(password)
			if not public_key is None:
				u.public_key=public_key
			s.merge(u)
			s.commit()
			return True
	return False
開發者ID:fablabnbg,項目名稱:Matomat2,代碼行數:29,代碼來源:authentication.py

示例2: register_view

# 需要導入模塊: from database import User [as 別名]
# 或者: from database.User import password [as 別名]
    def register_view(self):
        form = RegistrationForm(request.form)
        if helpers.validate_form_on_submit(form):
            user = User()

            form.populate_obj(user)
            # we hash the users password to avoid saving it as plaintext in the db,
            # remove to use plain text:
            user.password = generate_password_hash(form.password.data)

            db.session.add(user)
            db.session.commit()

            login.login_user(user)
            return redirect(url_for('.index'))
        link = '<p>Already have an account? <a href="' + url_for('.login_view') + '">Click here to log in.</a></p>'
        self._template_args['form'] = form
        self._template_args['link'] = link
        return super(MyAdminIndexView, self).index()
開發者ID:Zuph,項目名稱:MakerManager,代碼行數:21,代碼來源:MakerManager.py

示例3: register_view

# 需要導入模塊: from database import User [as 別名]
# 或者: from database.User import password [as 別名]
def register_view():
    form = RegistrationForm(request.form)
    if form.validate_on_submit():
        user = User()

        form.populate_obj(user)
        user.salt = str(time.time())

        hash_password = hashlib.sha512()
        hash_password.update(user.salt + user.password)
        user.password = hash_password.hexdigest()

        db.session.add(user)
        db.session.commit()

        login.login_user(user)
        flash('You were registered', 'info')
        return redirect(url_for('show_challenges'))

    return render_template('form.html', form=form)
開發者ID:HackGyver,項目名稱:challenges,代碼行數:22,代碼來源:login.py


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