本文整理汇总了Python中auth.models.User.password方法的典型用法代码示例。如果您正苦于以下问题:Python User.password方法的具体用法?Python User.password怎么用?Python User.password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth.models.User
的用法示例。
在下文中一共展示了User.password方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signup
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import password [as 别名]
def signup():
if request.method == "POST":
username = request.form["username"]
password = request.form["password"]
verify = request.form["verify"]
email = request.form["email"]
if valid_username(username) and valid_password(password)\
and valid_email(email) and password == verify:
user = User(username=username, email=email)
user.password = password
for exist in User.objects(username=username):
if user.username == exist.username:
flash(u"Username or Email already exist!!")
return redirect("/login")
for exist in User.objects(email=email):
if user.email == exist.email:
flash(u"Username or Email already exist!!")
return redirect("/login")
user.save()
login_user(user)
return redirect("/wiki/home")
else:
flash(u"Invalid Username or Password or Email!!")
return redirect("/signup")
return render_template("/auth/signup.html")
示例2: other_user
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import password [as 别名]
def other_user():
from auth.models import User
user = User()
user.username = 'Luke_Skywalker'
user.email = '[email protected]'
user.password = user.generate_password(password='12345678')
user.save(commit=True)
return user
示例3: user
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import password [as 别名]
def user():
from auth.models import User
user = User()
user.username = 'Darth_Vader'
user.email = '[email protected]'
user.password = user.generate_password(password='12345678')
user.save(commit=True)
return user
示例4: post
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import password [as 别名]
def post(self, *args, **kw):
form = request.form
try:
new_user = User(username=form['username'], email=form['email'], role=Role.objects(name="User").first())
new_user.password = form['password']
new_user.save()
except NotUniqueError, e: # email or username is not unique
if re.match(r'.*\$email.*', str(e)):
return jsonify(status="not-unique", message=u"Email has already confirmed.")
elif re.match(r'.*\$username.*', str(e)):
return jsonify(status="not-unique", message=u"Username has already confirmed.")
示例5: post
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import password [as 别名]
def post(self):
from auth.models import User
form = self._form()
if form.validate():
email = form.email.data
pw = form.password.data
u = User(email=email)
u.password = pw
login_user(u)
self.flash("Thank you for signing up {}".format(email))
return self.redirect('core.index')
return self.redirect('auth.signup')
示例6: register_do
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import password [as 别名]
def register_do(request):
password = request.GET.get('password')
password_repeat = request.GET.get('password_repeat')
if password != password_repeat:
return HttpResponseRedirect('/auth/register')
logging.info( password)
logging.info( password_repeat)
user = User()
user.username = request.GET.get('name')
user.password = request.GET.get('password')
user.email = request.GET.get('email')
user.mobile = request.GET.get('mobile')
user.save()
return HttpResponseRedirect('/auth/login')
示例7: post
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import password [as 别名]
def post(self):
from flask_xxl.apps.auth.models import User
form = self._form()
if form.validate():
email = form.email.data
pw = form.password.data
u = User(email=email)
u.password = pw
try:
u.save()
login_user(u)
self.flash("Thank you for signing up {}".format(email),'success')
return self.redirect('core.index')
except:
self.flash("an error occured while updating the database","danger")
return self.redirect('auth.signup')
示例8: login
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import password [as 别名]
def login():
password = request.form.get('inputPassword')
username = request.form.get('inputUsername')
user = User()
user.username = username
user.password = password
remember = False
if request.form.get('remember_me') == 'on':
remember = True
login_user(user, remember=remember)
rest = Rest()
user.other = rest.get('/auth/user')
# login_user(user, remember=remember)
if user.other.get('message'):
flash(user.other.get('message'), 'error')
logout_user()
return redirect(request.form.get('request_url'))