Exemple #1
0
def init_data():
	"""
	init data
	"""	
	from domain.model.user import User

	sha1 = hashlib.sha1()
	sha1.update('123456')

	user = User("*****@*****.**")
	user.nickname = 'fainle'
	user.password = sha1.hexdigest()

	db_session.add(user)
	db_session.commit()
Exemple #2
0
def init_data():
    """
    init data
    """
    from domain.model.user import User

    sha1 = hashlib.sha1()
    sha1.update('123456')

    user = User("*****@*****.**")
    user.nickname = 'fainle'
    user.password = sha1.hexdigest()

    db_session.add(user)
    db_session.commit()
Exemple #3
0
def register():
    register_form = RegisterForm(request.form)
    if request.method == 'POST':
        if register_form.validate():
            user = User(register_form.email.data)
            user.nickname = register_form.nickname.data
            sha1 = hashlib.sha1()
            sha1.update(register_form.password.data)
            user.password = sha1.hexdigest()
            db_session.add(user)
            db_session.commit()
            session['user_id'] = user.id
            session['nickname'] = user.nickname
            return redirect(request.args.get('next') or '/user')
    return render_template('/user/register.html', registerform=register_form)
 def authenticate(self, login, password_hash):
     """Check the login and password hash match"""
     user_obj = User.objects(login=login).first()
     if user_obj is None:
         return None
     if user_obj.passkey != HashUtils().salt_password(login, password_hash):
         return False
     return user_obj.to_dict()
Exemple #5
0
def register():
    register_form = RegisterForm(request.form)
    if request.method == 'POST':
        if register_form.validate():
            user = User(register_form.email.data)
            user.nickname = register_form.nickname.data
            sha1 = hashlib.sha1()
            sha1.update(register_form.password.data)
            user.password = sha1.hexdigest()
            db_session.add(user)
            db_session.commit()
            session['user_id'] = user.id
            session['nickname'] = user.nickname
            return redirect(request.args.get('next') or '/user')
    return render_template('/user/register.html',
                           registerform=register_form
    )