当前位置: 首页>>代码示例>>Python>>正文


Python User.password方法代码示例

本文整理汇总了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
开发者ID:moloch--,项目名称:RootTheBox,代码行数:36,代码来源:PublicHandlers.py

示例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
开发者ID:iamcm,项目名称:bottle-inventory,代码行数:9,代码来源:user_test.py

示例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})
开发者ID:x100up,项目名称:analystics,代码行数:33,代码来源:InstallController.py

示例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')   
开发者ID:iamcm,项目名称:consensus,代码行数:32,代码来源:app.py

示例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
开发者ID:ThinkmanWang,项目名称:ThinkNews-Server,代码行数:28,代码来源:user_db_utils.py

示例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/')
开发者ID:x100up,项目名称:analystics,代码行数:49,代码来源:AdminUserController.py

示例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
开发者ID:iamcm,项目名称:jug,代码行数:10,代码来源:BaseTest.py

示例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
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:12,代码来源:Helpers.py

示例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)
开发者ID:iamcm,项目名称:bottle-inventory,代码行数:13,代码来源:user_test.py

示例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
开发者ID:iamcm,项目名称:bottle-inventory,代码行数:14,代码来源:user_test.py

示例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
开发者ID:WeiEast,项目名称:RootTheBox,代码行数:16,代码来源:PublicHandlers.py

示例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"})
开发者ID:SanghoYoon,项目名称:FuckingNEIS,代码行数:18,代码来源:happen.py

示例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
开发者ID:ThinkmanWang,项目名称:ThinkNews-Server,代码行数:20,代码来源:user_db_utils.py

示例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())
开发者ID:di,项目名称:daywrite,代码行数:22,代码来源:__init__.py

示例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')
开发者ID:eunseo9808,项目名称:fakeArtist,代码行数:26,代码来源:test.py


注:本文中的models.User.User.password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。