本文整理汇总了Python中model.User.password方法的典型用法代码示例。如果您正苦于以下问题:Python User.password方法的具体用法?Python User.password怎么用?Python User.password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.password方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clientRegister
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def clientRegister(self, data):
try:
rdata = {}
username = data['username']
if not username:
self.sendAPI(1,447,'Value empty')
return
if not isinstance(username, basestring):
self.sendAPI(1,448,'Value is wrong data type')
return
if len(username) > 50:
self.sendAPI(1,449,'Value exceeds maximum input length')
return
user = User(username)
if user.exist():
self.sendAPI(1,441,'Credentials already exist')
return
user.token = self.getNewToken()
user.password = self.getNewPassword()
user.save()
rdata['password'] = user.password
self.sendAPI(0,241,'User registered',rdata)
except (KeyError, TypeError):
self.sendAPI(1,401,'Not in reference format')
示例2: fake_db
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def fake_db():
userMap={}
groupMap={}
for i in range(10):
user = User("user%s"%i,"user%[email protected]"%i)
user.password="test"
db.session.add(user)
db.session.commit()
userMap[user.id]=user;
for i in range(5):
userid = random.choice(userMap.keys())
group = Group(userid, "group%s"%i)
group.describe = "".join([chr(random.choice(range(65,90))) for i in range(10)])
db.session.add(group)
db.session.commit()
groupMap[group.id]=group
db.session.commit()
for userid,user in userMap.items():
group=random.choice(groupMap.values());
group.add_member(userid)
for groupid,group in groupMap.items():
user=random.choice(userMap.values());
group.add_member(user.id)
return dict();
示例3: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def post(self):
self.session[LOGIN_NEXT_PAGE_KEY] = self.URL
roles=Role.all()
if roles.count() == 0:
# No roles were set up, set them up now
adminRole = Role()
adminRole.name=ROLE_ADMIN
adminRole.put()
role = Role()
role.name=ROLE_DELIVERY_GUY
role.put()
role = Role()
role.name=ROLE_COOK
role.put()
role = Role()
role.name=ROLE_AGENT
role.put()
user = User()
user.email = self.request.get("adminEmail")
user.password = "[email protected]#"
m = hashlib.md5()
encodedString = self.request.get("adminPassword").encode('ascii', errors='replace')
m.update(encodedString)
user.passwordHash = str(m.hexdigest())
user.activated = True
user.role = adminRole
user.put();
template = jinja_environment.get_template('templates/setup/setupSuccess.html')
self.printPage("Sikeres inicializálás", template.render(), True, True)
else:
template = jinja_environment.get_template('templates/setup/alreadySetUp.html')
self.printPage("Korábban inicializálva", template.render(), True, True)
示例4: register_post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def register_post():
# Create the user object to store our data
user = User()
user.first_name = request.form.get('first_name')
user.last_name = request.form.get('last_name')
user.email = request.form.get('email')
user.phone = request.form.get('phone')
user.password = request.form.get('password')
user.role = request.form.get('role')
existing = db_session.query(User).filter_by(email=user.email).first()
if existing:
flash("Email already in use", "error")
return redirect(url_for("user_login_get"))
# Add the user object to the database
db_session.add(user)
# Save the user in the database
db_session.commit()
# # Redirect user to landing page
return redirect(url_for("traveler_view_trip"))
示例5: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def post(self):
#if self.get_current_user():
# self.redirect("/")
# return
mobile = self.get_argument("mobile", None)
password = self.get_argument("password", None)
apassword = self.get_argument("apassword", None)
vcode = self.get_argument("vcode", None)
sharer = self.get_argument("sharer", None)
realname=self.get_argument("realname",None)
user = User()
user.mobile = mobile
user.realname = realname
user.password = User.create_password(password)
try:
user.validate()
if password and apassword:
if len(password) < 6:
self.flash("请确认输入6位以上新密码")
elif password != apassword:
self.flash("请确认新密码和重复密码一致")
elif len(realname) > 32:
self.flash("微信账号超出长度限制")
elif len(realname) < 2:
self.flash("微信账号太短")
else:
#if UserVcode.select().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).count() > 0:
# UserVcode.delete().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).execute()
user.save()
user.updatesignin()
self.session['user'] = user
if 'oauth' in self.session:
oauth = self.session['oauth']
o = Oauth()
o.uid = user.id
o.openid = oauth['id']
o.src = oauth['src']
o.save()
del self.session['oauth']
self.session.save()
User.update(credit = User.credit + 1).where(User.mobile == mobile).execute()
#if sharer != None
User.update(credit = User.credit + 1).where(User.mobile == sharer).execute()
self.flash("注册成功,请先登录。", "ok")
url="/signup?sharer="+user.mobile
self.redirect(url,permanent=True)
return
#else:
# self.flash("请输入正确的验证码")
else:
self.flash("请输入密码和确认密码")
except Exception, ex:
self.flash(str(ex))
示例6: register
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def register(email, pwd):
exists = User.objects(email=email)
if len(exists):
return {'success':False, 'error':'exists user'}
user = User(email=email)
user.password = User.encrypted_password(pwd)
user.save()
login_user(user)
return {'success': True}
示例7: adduser
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def adduser():
user=User()
requeststr = request.query_string
params=utils.getparam(unquote(requeststr))
user.username=params['username']
user.email=params['email']
user.password=params['password']
user.sex=params['sex']
user.adduser()
return jsonify(msg='0000')
示例8: regiest
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def regiest():
user = User()
user.username = request.form['username']
user.password=utils.getenctry(request.form['password'])
user.email = request.form['email']
user.adduser()
session['username'] = user.username
flash("Welcome, %s!" % session['username'])
return redirect(url_for('home'))
#return (jsonify(user=user.to_json()))
示例9: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def post(self):
if self.get_current_user():
self.redirect("/")
return
mobile = self.get_argument("mobile", None)
password = self.get_argument("password", None)
apassword = self.get_argument("apassword", None)
vcode = self.get_argument("vcode", None)
sharer = self.get_argument("sharer", None)
openid = self.get_argument("openid", None)
user = User()
user.mobile = mobile
user.openid = openid
print openid
user.password = User.create_password(password)
try:
user.validate()
if password and apassword:
if len(password) < 6:
self.flash("请确认输入6位以上新密码")
elif password != apassword:
self.flash("请确认新密码和重复密码一致")
else:
if UserVcode.select().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).count() > 0:
UserVcode.delete().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).execute()
user.save()
if 'oauth' in self.session:
oauth = self.session['oauth']
o = Oauth()
o.uid = user.id
o.openid = oauth['id']
o.src = oauth['src']
o.save()
del self.session['oauth']
self.session.save()
print sharer
User.update(credit = User.credit + 1).where(User.mobile == mobile).execute()
#if sharer != None
User.update(credit = User.credit + 1).where(User.mobile == sharer).execute()
self.flash("注册成功,请先登录。", "ok")
self.redirect("/signin")
return
else:
self.flash("请输入正确的验证码")
else:
self.flash("请输入密码和确认密码")
except Exception, ex:
self.flash(str(ex))
示例10: register
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def register():
form = RegistrationForm()
if form.validate_on_submit():
user = User(email = form.email.data, username = form.username.data)
user.password = form.password.data
db.session.add(user)
db.session.commit()
token = user.generate_confirmation_token()
send_mail(user.email, 'Confirm Your Account', 'mail/confirm', user = user, token = token)
flash('A confirmation email has been sent to you by email.')
return redirect(url_for('index'))
return render_template('auth/register.html', form = form)
示例11: test_edit_move_different_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def test_edit_move_different_user(self, tmpdir):
username = 'some different user'
password = 'some other password'
with app.test_request_context():
user = User(username=username, active=True)
user.password = openmoves.app_bcrypt.generate_password_hash(password, 10)
db.session.add(user)
db.session.commit()
self._login(username=username, password=password)
data = {'name': 'activity', 'pk': 1}
response = self.client.post('/moves/1', data=data)
assert response.status_code == 404
示例12: load_users
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def load_users(session):
with open('seed_data/u.user', 'rb') as csvfile:
userreader = csv.reader(csvfile, delimiter = '|')
for userrow in userreader:
u = User()
u.id = userrow[0]
u.age = userrow[1]
u.gender = userrow[2]
u.occupation = userrow[3]
u.zipcode = userrow[4]
u.email = None
u.password = None
session.add(u)
示例13: user_register
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def user_register(**kwargs):
form = RegisterationForm()
if form.validate_on_submit():
username = form.name.data
email = form.email.data
#user1 = User.query.filter_by(username=name).first()
#user2 = User.query.filter_by(email=email).first()
#if (user1 is None) and (user2 is None):
db = get_db()
user_tmp = User(username=username, email=email)
user_tmp.password = form.password.data
db.session.add(user_tmp);
return dict(success=1)
else:
return dict(fail=1)
示例14: test_login_valid
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def test_login_valid(self, tmpdir):
username = 'test_user'
password = 'test password'
with app.test_request_context():
User.query.delete(synchronize_session=False)
user = User(username=username, active=True)
user.password = openmoves.app_bcrypt.generate_password_hash(password, 10)
db.session.add(user)
db.session.commit()
response = self._login()
response_data = self._validate_response(response, tmpdir)
assert u"<title>OpenMoves – Dashboard</title>" in response_data
示例15: register
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import password [as 别名]
def register():
form = RegisterForm()
if form.validate_on_submit():
user = User(email=form.email.data,
username=form.username.data)
user.password = form.password.data
user.save()
token = user.generate_confirmation_token()
send_email(current_user.email, "Confirm your email", "email/confirm",
user=current_user, token=token)
# send_async_email(current_user.email, "Confirm your email", "email/confirm",
# user=current_user, token=token)
flash("A confirmation email has been sent to your email.")
return redirect(url_for("login"))
return render_template("register.html", form=form)