예제 #1
0
    def validator(self):
        token = None
        if 'user_token' in request.form:
            token = request.form['user_token']
        elif 'user_token' in request.args:
            token = request.args.get('user_token')

        if token:
            this_user = User.get_user(user_token=token)
            if this_user and this_user.token_matches(token):
                return True
        return False
예제 #2
0
    def validator(self):
        token = None
        if 'user_token' in request.form:
            token = request.form['user_token']
        elif 'user_token' in request.args:
            token = request.args.get('user_token')

        if token:
            this_user = User.get_user(user_token=token)
            if this_user and this_user.token_matches(token):
                return True
        return False
예제 #3
0
def register():
    if request.method == 'POST':
        email = request.form['email']
        pw1, pw2 = request.form['password1'], request.form['password2']

        if User.get_user(email=email):
            flash("That email is already taken!", 'error')
            return render_template('register.html')
        elif len(pw1) < 6:
            flash("Passwords must be at least six characters!", 'error')
            return render_template('register.html', email=email)
        elif pw1 != pw2:
            flash("Passwords do not match!", 'error')
            return render_template('register.html', email=email)

        new_user = User(email, pw1)
        new_user.save()
        flash("Account successfully created.", 'success')
        return render_template('login.html')
    else:
        return render_template('register.html')
예제 #4
0
def logout():
    """ Called when an API user wishes to log out and stop using their token. """
    auth_user = User.get_user(user_token=request.form['user_token'])
    auth_user.clear_token()
    return JSON_SUCCESS()
예제 #5
0
def get_test_user():
    user = User.get_user(email='test')
    if not user:
        user = User('test', base64.b64encode(os.urandom(16)))
    return user
예제 #6
0
파일: auth.py 프로젝트: ZachAnders/OPLabs
def get_test_user():
    user = User.get_user(email='test')
    if not user:
        user = User('test', base64.b64encode(os.urandom(16)))
    return user
예제 #7
0
def test_func():
    """ Test function for logged in users. """
    auth_user = User.get_user(user_token=request.form['user_token'])

    return JSON_SUCCESS(your_email=auth_user.email)
예제 #8
0
def logout():
    """ Called when an API user wishes to log out and stop using their token. """
    auth_user = User.get_user(user_token=request.form['user_token'])
    auth_user.clear_token()
    return JSON_SUCCESS()