Exemplo n.º 1
0
def register():
    error = None
    form = SignupForm()
    if request.method == 'POST':
        if request.form.get('submit') == 'Cancel':
            return redirect(url_for('UsersFiles.login'))
        
        elif form.validate_on_submit():
            try: 
                user = Users(
                    user_name=form.user_name.data,
                    user_password=form.user_password1.data 
                )
                db.create_all()
                db.session.add(user)
                db.session.commit()
                Log("SIGNUP")

                login_user(user)
                Log("LOGIN")
                # add hash
                addCompHash(str(current_user))
                flash('You are just login!')
                return redirect(url_for('HomeFiles.home'))

            except:
                error = 'Signup Fail'
                db.session.rollback()
                Log("SIGNUP FAIL")
            #     trace= get_current_traceback(skip=1, show_hidden_frames=True,
            # ignore_system_exceptions=False)
            # return redirect(url_for('ShareFiles.stack_trace', trace=trace))
            

    return render_template('register.html', form = form, error = error) 
Exemplo n.º 2
0
def login(): 

    error = None
    form = LoginForm()
    
    if request.method == 'POST':
        if request.form.get('submit') == 'Register':
            return redirect(url_for('UsersFiles.register'))
        
        elif form.validate_on_submit():
            session.permanent = True
            Log("LOGIN")
            # compare hash
            addCompHash(str(current_user))
            
            flash('You are just login!')
            
            try: 
                if isHack(str(current_user)):
                    flash('!!!!! YOU GOT HACK !!!!!!')
            except:
                flash('First time login')

            return redirect(url_for('HomeFiles.home'))
        
        else:
            error = 'Invalid username or password. Please try again.'
            Log("LOGIN FAIL")

            return render_template('login.html', form=form, error=error)

    elif request.method == 'GET':
        return render_template('login.html', form=form)