本文整理汇总了Python中models.User.User.password方法的典型用法代码示例。如果您正苦于以下问题:Python User.password方法的具体用法?Python User.password怎么用?Python User.password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.User.User
的用法示例。
在下文中一共展示了User.password方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def create_user(self):
''' Add user to the database '''
if User.by_handle(self.get_argument('handle', '')) is not None:
raise ValidationError("This handle is already registered")
if self.get_argument('pass1', '') != self.get_argument('pass2', ''):
raise ValidationError("Passwords do not match")
user = User()
user.handle = self.get_argument('handle', '')
user.password = self.get_argument('pass1', '')
user.bank_password = self.get_argument('bpass', '')
user.name = self.get_argument('playername', '')
user.email = self.get_argument('email','')
team = self.get_team()
self.dbsession.add(user)
self.dbsession.add(team)
self.dbsession.commit()
# Avatar
avatar_select = self.get_argument('user_avatar_select', '')
if avatar_select and len(avatar_select) > 0:
user._avatar = avatar_select
elif hasattr(self.request, 'files') and 'avatar' in self.request.files:
user.avatar = self.request.files['avatar'][0]['body']
team.members.append(user)
if not options.teams:
if avatar_select and len(avatar_select) > 0:
team._avatar = avatar_select
elif hasattr(self.request, 'files') and 'avatar' in self.request.files:
team.avatar = self.request.files['avatar'][0]['body']
self.dbsession.add(user)
self.dbsession.add(team)
self.dbsession.commit()
self.event_manager.user_joined_team(user)
return user
示例2: create_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def create_user(self):
u = User(_DBCON)
u.email = self.EMAIL
u.password = self.PASSWORD
u.save()
return u
示例3: get
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def get(self, *args, **kwargs):
self.errors = []
# перезагружаем конфигурацию приложения
self.application.loadConfiguration()
self.removeDBSessions()
# миграция БД
password = None
try:
connection = self.getDBSession()
migrate(connection = connection)
except BaseException as exception:
self.errors.append(u'Ошибка при миграции БД: ' + exception.message)
else:
# create admin user
password = hashlib.sha256(str(time.time())).hexdigest()[5:11]
user = User()
user.fullname = 'Admin'
user.login = 'admin'
user.password = hashlib.sha256(password).hexdigest()
user.role = User.ROLE_ADMIN
try:
connection.merge(user)
connection.commit()
except BaseException as exception:
self.errors.append(u'Ошибка при создани пользователя: ' + exception.message)
else:
self.application.isInstalled = True
self.render('install/end.jinja2', {'errors': self.errors, 'admin_pass': password})
示例4: index
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def index():
user = FacebookClient().process(bottle.request.GET['code'])
if user:
users = EntityManager(_DBCON).getAll(User, filterCriteria={'facebookUserId':user['id']})
if users:
_id = users[0]._id
else:
_id = None
u = User(_DBCON, _id=_id)
u.username = user['name']
u.password = user['id']
u.valid = False
u.facebookUserId = user['id']
u.save()
s = Session(_DBCON)
s.userid = u._id
s.ip = bottle.request.get('REMOTE_ADDR')
s.useragent = bottle.request.get('HTTP_USER_AGENT')
s.save()
s.set_cookie()
bottle.redirect('/')
else:
bottle.redirect('/login')
示例5: user_login
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def user_login(user_name, password):
conn = g_dbPool.connection()
cur=conn.cursor()
cur.execute("select * from view_user where user_name=%s AND password=%s" , (user_name, password))
#cur.execute("select * from view_user where user_name=\"18621675203\" AND password=\"a0a475cf454cf9a06979034098167b\"")
rows=cur.fetchall()
lstUser = []
for row in rows:
user = User()
user.id = row[0]
user.user_name = row[1]
user.password = row[2]
user.token = row[3]
user.create_time = row[4]
user.expire_time = row[5]
lstUser.append(user)
cur.close()
if (lstUser != None and len(lstUser) >= 1):
userRet = lstUser[0]
userRet = insert_or_update_token(userRet)
return userRet
else:
return None
示例6: post
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def post(self):
self.adminAuthenticated()
db = self.getDBSession()
userId = self.get_argument('userId', '')
isNewUser = False
if len(userId):
user = db.query(User).filter_by(userId = userId).first()
if not user:
raise RuntimeError('Can`t find user for editing')
else:
isNewUser = True
user = User()
user.login = self.get_argument('login', '')
password = self.get_argument('password', '')
user.fullname = self.get_argument('fullname', '')
errors = []
if len(str(user.login)) < 4:
errors.append(u'Логин должен быть не менее 4 символов')
else:
if isNewUser:
count = db.query(User).filter_by(login = user.login).count()
else:
count = db.query(User).filter(User.login == user.login).filter(User.userId != user.userId).count()
if count > 0:
errors.append(u'Вы не можете использовать этот логин')
# только меняется только при вводе нового
if isNewUser or len(password):
if len(password) < 6:
errors.append(u'Пароль должен быть не менее 6 символов')
else:
user.password = hashlib.sha256(password).hexdigest()
if len(str(user.fullname)) < 1:
errors.append(u'Имя не должно быть пустое')
if len(errors):
user.password = ''
db.commit()
self.render('admin/users/users_edit.jinja2', {'user':user, 'errors':errors})
else:
db = self.getDBSession()
db.merge(user)
db.commit()
self.redirect('/admin/users/')
示例7: create_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def create_user(self, email='[email protected]', password='passpass', valid=True):
u = User(self.conn)
u.email = email
u.password = password
u.valid = valid
u.save()
return u
示例8: create_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def create_user():
user = User.by_handle("HacKer")
if user is None:
user = User()
user.handle = "HacKer"
user.password = "TestPassword"
user.bank_password = "Test123"
dbsession.add(user)
dbsession.commit()
return user
示例9: test_change_password_bad
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def test_change_password_bad(self):
u = self.create_activated_user()
u = User(_DBCON, email=self.EMAIL, password=self.PASSWORD)
u.password = 'new'
u.save()
#now try and get that user again with the new email and password
u = User(_DBCON, email=self.EMAIL, password='new')
self.assertTrue(u._id is None)
示例10: create_activated_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def create_activated_user(self):
"""
shortcut to save having to activate the user each time we
create one
"""
u = User(_DBCON)
u.email = self.EMAIL
u.password = self.PASSWORD
u.valid = True
u.save()
return u
示例11: create_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def create_user(self, team):
''' Add user to the database '''
if self.get_argument('pass1', '') != self.get_argument('pass2', ''):
raise ValidationError("Passwords do not match")
user = User()
user.handle = self.get_argument('handle', '')
user.password = self.get_argument('pass1', '')
user.bank_password = self.get_argument('bpass', '')
team.members.append(user)
self.dbsession.add(user)
self.dbsession.add(team)
self.dbsession.commit()
self.event_manager.user_joined_team(user)
return user
示例12: create_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def create_user():
new = User()
try:
new.school = request.form["school"]
new.name = request.form["name"]
new.admission_year = request.form["admission_year"]
new.email = request.form["email"]
new.password = request.form["password"]
except:
pass
new.photo_url = request.form.get("photo_url", None)
db.session.add(new)
db.session.commit()
return jsonify({"result": "succces", "description": "create_user"})
示例13: get_all_user_from_pool
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def get_all_user_from_pool():
conn = g_dbPool.connection()
cur=conn.cursor()
SQL="select * from user"
cur.execute(SQL)
rows=cur.fetchall()
lstUser = []
for row in rows:
user = User()
user.id = row[0]
user.user_name = row[1]
user.password = row[2]
lstUser.append(user)
cur.close()
return lstUser
示例14: post_register
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def post_register():
form = RegisterForm()
if form.validate_on_submit():
email_hash = md5.new(form.email.data.strip().lower()).hexdigest()
user = User(email=form.email.data, email_hash=email_hash)
user.password = generate_password_hash(form.password.data)
user.registered = True
'''
# Create a stripe customer
stripe.api_key = app.config['STRIPE_SECRET_KEY']
customer = stripe.Customer.create(email=user.email)
user.stripe_id = customer.id
'''
user.save()
login_user(user)
flash("Successfully registered")
return redirect(url_for("index"))
return render_template('register.html', form=RegisterForm())
示例15: create
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import password [as 别名]
def create():
if request.method=="POST":
check=True
if not 'nick' in request.form:
check=False
if not 'id' in request.form:
check=False
if not 'pw' in request.form:
check=False
if not check:
return render_template('signup.html', notenough=True)
new=User()
new.id=request.form['id']
new.name=request.form['nick']
new.password=request.form['pw']
db.session.add(new)
db.session.commit()
return redirect('/login')
return render_template('signup.html')