Exemplo n.º 1
0
def userLogin():
    if current_user.is_authenticated:
        next = request.args.get('next')
        if next:
            return redirect(next)
    else:
        if current_user.is_active:
            return current_user.userid
        else:
            form = LoginForm()
            if form.validate_on_submit():
                user = User.objects(username=form.username.data).first()
                if user is not None and user.verify_password(form.password.data):
                    login_user(user, form.rememberme.data)
                    return redirect(url_for('index.indexPage'))
                flash('Invalid username or password.')
            return render_template('login/login.html', form=form)
Exemplo n.º 2
0
def index(username):
    if username:
        user = User.objects(username=username).first()
        pair = Pair.query(user.userid).first()
        uid = pair.uid
        print(uid)
        try:
            # if not socketio.server:
            #     return render_template('message/msgIndex.html')
            # if socketio.server.namespace_handlers.has_key('/{}'.format(uid)):
            #     print('room has created')
            # else:
            #     socketio.on_namespace(MessageRoom('/{}'.format(uid)))
            #     print('new room created')
            return render_template('message/chatroom.html', roomid=uid)
        except Exception as e:
            print(str(e))
            return 'somethin wrong'