本文整理汇总了Python中models.user.User.password方法的典型用法代码示例。如果您正苦于以下问题:Python User.password方法的具体用法?Python User.password怎么用?Python User.password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.password方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def post(self):
fname = self.request.get("first_name")
lname = self.request.get("last_name")
dname = self.request.get("display_name")
email = self.request.get("email")
password = self.request.get("password")
rpassword = self.request.get("password_confirmation")
#logging.critical(email)
if password != rpassword:
self.error = "Password Not Match"
self.redirect('/create/account?error='+self.error)
user = User.get_by_id(id=email)
logging.critical(user)
if user:
self.error = "Email already exists!"
self.redirect('/create/account?error='+self.error)
user = User(id=email)
user.fname = fname
user.lname = lname
user.dname = dname
user.email = email
user.password = password
user.put()
self.logged_this_user(user)
self.tv["user"] = True
self.redirect('/dashboard')
示例2: register
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def register():
from forms.registration import ProfessorRegistrationForm
form = ProfessorRegistrationForm()
if form.validate_on_submit():
user = User()
user.name = form.name.data
user.second_name = form.second_name.data
user.middle_name = form.middle_name.data
user.birthday = form.birthday.data
user.password = form.password.data
user.email = form.email.data
# professor = Professor()
# professor.post = form.post.data
# professor.academic_degree = form.academic_degree.data
# professor.rank = form.rank.data
# professor.cathedra_id = form.cathedra.data.id
# professor.user = user
db.session.add(user)
# db.session.add(professor)
try:
db.session.commit()
except Exception:
flash('Problem with registering')
return redirect(url_for('site.register'))
flash('Thanks for registering')
return redirect(url_for('site.login'))
return render_template('site/register/register.html', form=form)
示例3: create_user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def create_user(self):
user = User()
user.username = 'test_username'
user.password = 'test_password'
user.name = 'test_name'
user.email = '[email protected]'
user.save()
return user
示例4: put
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def put(self):
user = User()
user.username = 'kx'
user.password = '123456'
user.token = 'ddd'
user.ttl = '7200'
db.session.add(user)
db.session.commit()
return {'message': 'add success'}
示例5: user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def user():
fake = Faker()
user_data = {"username": fake.first_name(), "password": fake.text(10)}
user = User()
user.create(user_data)
user.password = user_data.get("password")
return user
示例6: register
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def register(email, username, password):
user = User()
user.email = email
user.username = username
user.password = password
errors = user.validate_me()
if errors:
print(errors)
return {'errors': errors}
else:
res = user.save_me()
if 'id' in res.keys():
user = User.objects(id=res['id']).first()
Inventory(owner=user.to_dbref(),
name='Basic',
is_basic=True).save()
return res
示例7: register
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def register(email, hashed_password, first, last):
user1 = User()
qry = User.query(User.email==email, User.password==hashed_password, User.first_name==first, User.last_name==last).get()
logging.info(qry)
if qry:
return 2
qry = user1.check_user_exist_by_email(email)
try:
qry.password = hashed_password
token = qry.put()
return token.id()
except:
user1.email = email
user1.password = hashed_password
user1.first_name = first
user1.last_name = last
token = user1.put()
return token.id()
示例8: post
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def post(self, *args, **kwargs):
name = self.get_argument('name', '')
family = self.get_argument('family', '')
username = self.get_argument('username', '')
password = self.get_argument('password', '')
type = self.get_argument('type', '')
permissions = Redis.get(key='permissions', type='list')
try:
obj = Controller()
obj.name = name
obj.family = family
obj.username = username
obj.password = password
obj.type = type
obj.save()
self.write('ok')
self.render('register.html', action='done', permissions=permissions)
except Exception, e:
self.write(e.message)
self.render('register.html', action='error', permissions=permissions)
示例9: post
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def post(self):
try:
email = self.get_argument("email")
password = self.get_argument("password")
if len(password) < 6:
raise ValidationError('password')
password = self.md5(password.encode('utf-8'))
user = User()
user.email = email
user.password = password
user.validate()
except ValidationError as e:
self.ERRORS[str(e)] = True
self.render_password(email=email)
else:
user.save()
self.login(password, email)
self.render_complete()
示例10: create_user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def create_user():
# print request.json
if not request.json or not 'email' in request.json:
abort(400)
new_user = User()
new_user.name = request.json['name']
new_user.email = request.json['email']
new_user.active = request.json['active']
new_user.password = request.json['password']
new_user.hash_password()
# Acá sacar la fecha y hora actual.
current_time = datetime.datetime.now()
new_user.registry_date = request.json.get('registry_date', current_time)
# Controlamos error en caso de que se inserte un usuario que ya existe
try:
new_user.save()
except Exception, e:
print e
abort(400)
示例11: main
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
DBSession.add(Item(
"Nutrigrain Raspberry",
"038000358210",
14.37,
0.47,
1,
True
))
DBSession.add(Item(
"Clif Bar: Chocolate Chip",
"722252100900",
1.25,
1.17,
5,
True
))
DBSession.add(Item(
"Clif Bar: Crunchy Peanut Butter",
"722252101204",
1.25,
1.14,
5,
True
))
DBSession.add(Item(
"Coke (12 oz)",
"04963406",
0.42,
0.37,
12,
True
))
# user = User(
# "zakir",
# "95951361",
# "Zakir Durumeric"
# )
# user.role = "administrator"
# user.password = "test"
# DBSession.add(user)
user = User(
"bradjc",
"11519022",
"Brad Campbell"
)
user.role = "administrator"
user.password = "test"
DBSession.add(user)
user = User(
"ppannuto",
"64880621",
"Pat Pannuto"
)
user.role = "administrator"
user.password = "test2"
DBSession.add(user)
user = User(
"betty",
"00000000",
"Betty"
)
user.role = "serviceaccount"
user.password = "cb"
DBSession.add(user)
account.get_virt_account("chezbetty")
account.get_cash_account("cashbox")
account.get_cash_account("chezbetty")
account.get_cash_account("btcbox")
示例12: register
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def register(params, device):
rtype = params.get('rtype', None)
name = params.get('name', None)
phone = params.get('phone', None)
password = params.get('password', None)
vcode = params.get('vcode', None)
uname = params.get('username', '')
cname = params.get('cname', '')
notice = params.get('notice', "true")
if not phone or not password or not vcode or not name or not rtype or not notice or not rtype.isdigit():
return {"error_code":20021, "msg":"parameters required"}
rtype = int(rtype)
if not validate.is_phone(phone):
return {"error_code":20022, "msg":"phone invalid"}
# freelancer: 1, client: 2, client_person: 3
if rtype not in [1, 2, 3]:
return {"error_code":20022, "msg":"user type invalid"}
if rtype == 2 and not cname or len(cname) > 100:
return {"error_code":20022, "msg":"user type invalid or cname too long"}
if not validate.is_verify_code(vcode):
return {"error_code":20024, "msg":"verify code invalid"}
if User.select().where(User.phone == phone).first():
return {"error_code":20025, "msg":"user is exists"}
if rtype != 1:
username = phone
else:
# freelancer do not use username, just use phone to register
# username = uname
username = phone
if not utils.is_username(username):
return {"error_code":20023, "msg":"username invalid"}
if User.select().where(User.username == username).first():
return {"error_code":20025, "msg":"user is exists"}
res = verify_code(phone=phone, code=vcode)
if res['error_code'] != 0:
return res
user_id = GUID.guid()
team_id = GUID.guid()
with database.atomic() as txn:
try:
pwd, salt = generate_password(password.encode('utf-8'))
user = User()
user.id = user_id
user.username = username
user.password = pwd
user.salt = salt
user.phone = phone
#user.verifycode = vcode
user.save(force_insert=True)
profile = Profile()
profile.user = user
profile.name = name
profile.avatar = widget.avatar()
if notice == "true":
profile.is_notice = True
profile.save()
party = Party()
party.user = user
party.vip = False
party.connects = 60
party.agency_connects = 60
party.save()
margin = Margin()
margin.user = user
margin.save()
if rtype == 1:
user.identify = 'f%s' % user.id
user.app_identify = 'f%s' % user.id
user.status = "unactive"
user.to_dev = True
user.to_req = False
user.save()
queue.to_queue({"type":"user_register", "user_id":user.id})
else:
team = Team()
team.id = team_id
team.user = user
if rtype == 2:
team.name = cname
else:
team.name = "个人需求方"
team.team_type = 'client'
team.status = "normal"
#.........这里部分代码省略.........
示例13: print
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
#!/usr/bin/python3
import sys
import os
sys.path.insert(1, os.path.join(os.path.split(__file__)[0], '../../..'))
from models import storage
from models.base_model import BaseModel
from models.user import User
all_objs = storage.all()
print("-- Reloaded objects --")
for obj_id in all_objs.keys():
obj = all_objs[obj_id]
print(obj)
print("-- Create a new User --")
my_user = User()
my_user.first_name = "Betty"
my_user.last_name = "Holberton"
my_user.email = "[email protected]"
my_user.password = "root"
my_user.save()
print(my_user)
示例14: main
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
# Setup a few initial items
DBSession.add(Item(
"Nutrigrain Raspberry",
"038000358210",
14.37,
0.47,
False,
False,
3,
True
))
DBSession.add(Item(
"Clif Bar: Chocolate Chip",
"722252100900",
1.25,
1.17,
False,
False,
12,
True
))
DBSession.add(Item(
"Clif Bar: Crunchy Peanut Butter",
"722252101204",
1.25,
1.14,
False,
False,
11,
True
))
coke = Item(
"Coke (12 oz)",
"04963406",
0.42,
0.37,
True,
False,
8,
True
)
DBSession.add(coke)
# Add a test box
coke_box = Box(
"Coke 32 pack", # name
"049000042511", # barcode
True, # bottle deposit
False, # sales tax
32.00, # wholesale
# enabled implicit True
)
DBSession.add(coke_box)
DBSession.flush()
DBSession.add(BoxItem(coke_box, coke, 32, 100))
# Add the betty user
DBSession.add(coke)
user = User(
"betty",
"00000000",
"Betty"
)
user.role = "serviceaccount"
user.password = "chezbetty"
DBSession.add(user)
# Add an admin user
user = User(
"admin",
"56785678",
"Administrator"
)
user.role = "administrator"
user.password = "chezbettyadmin"
DBSession.add(user)
# Init the accounts we need
account.get_virt_account("chezbetty")
account.get_cash_account("cashbox")
account.get_cash_account("safe")
account.get_cash_account("chezbetty")
account.get_cash_account("btcbox")
示例15: telegramWebHook
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import password [as 别名]
def telegramWebHook():
update = Update.de_json(request.get_json(force=True))
text = None
if getattr(update.message, 'document'):
gallery = Gallery().search(tgid = update.message.chat.id)
if gallery:
newfile = bot.getFile(update.message.document.file_id)
file_name = update.message.document.file_id
newfile.download(file_name)
writed = False
if os.path.exists(file_name):
writed = write_file(file_name, read_file(file_name, storage = 'local', append_path = False), acl = 'public-read', mime_type = update.message.document.mime_type)
thumbnail(file_name)
os.remove(file_name)
write_file('%s.json' % file_name, update.to_json())
if writed:
file_id = File(gallery_eid = gallery.eid, file_id = update.message.document.file_id)
file_id.save()
sendLink = getattr(gallery, 'sendLink', None)
if sendLink == 'True':
text = 'File URL: %s' % url_for('image', file_id = file_id.eid, _external = True, disable_web_page_preview = True)
else:
text = 'Failed to download file'
else:
text = 'Gallery does not exist, please create first'
pass
if getattr(update.message, 'text'):
args = update.message.text.split(' ', 2)
if args[0] == '/register':
text = 'Username:'
user = User().search(tgid = update.message.from_user.id)
if not user:
User(tgid = update.message.from_user.id).save()
text = 'Complete register: https://telegram.me/ACSGalleryBot?start=%s' % update.message.from_user.id
else:
text = 'User added to gallery'
# set gallery permission at this point because i have chat id
elif args[0] == '/start':
if len(args) > 1 and int(args[1]) == int(update.message.chat.id):
text = 'Username:'
bot.sendMessage(update.message.from_user.id, text, reply_markup = { 'force_reply' : True })
else:
text = update.to_json()
elif getattr(update.message, 'reply_to_message'):
if update.message.reply_to_message.text == 'Username:':
user = User().search(tgid = update.message.from_user.id)
if user:
user.username = update.message.text
user.save()
bot.sendMessage(update.message.chat.id, 'Password:', reply_markup = { 'force_reply' : True })
return 'ok'
elif update.message.reply_to_message.text == 'Password:':
user = User().search(tgid = update.message.from_user.id)
user.password = update.message.text
user.save()
text = 'User succesfuly registered'
elif args[0] == '/create':
if hasattr(update.message.chat, 'title'):
gallery = Gallery().search(tgid = update.message.chat.id)
if not gallery:
gallery = Gallery(tgid = update.message.chat.id, title = update.message.chat.title).save()
text = 'Gallery URL: %s' % url_for('gallery', id = gallery.eid, _external = True, _scheme = 'https')
else:
text = 'Bot only works in groups'
elif args[0] == '/remove':
gallery = Gallery().search(tgid = update.message.chat.id)
if gallery:
gallery.delete()
text = 'Gallery deleted'
else:
text = 'Gallery is not registered'
# TODO: Confirm
elif args[0] == '/config':
args.pop(0)
gallery = Gallery.search(tgid = update.message.chat.id)
if gallery:
if len(args) == 0:
text = g.config(update.message.chat.id)
elif len(args) == 1:
text = 'get one'
text = g.config(update.message.chat.id, args[0])
else:
text = g.config(update.message.chat.id, args[0], args[1])
else:
text = 'Gallery is not registered'
#else:
# text = update.to_json()
if text:
bot.sendMessage(update.message.chat.id, text, disable_web_page_preview=True)
return ""