Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice for placing login_required in better directory #1

Open
rendiya opened this issue Mar 15, 2017 · 1 comment
Open

Advice for placing login_required in better directory #1

rendiya opened this issue Mar 15, 2017 · 1 comment

Comments

@rendiya
Copy link

rendiya commented Mar 15, 2017


def login_required(f):
    @wraps(f)
    def wrap(*args, **kwargs):
        session.permanent = True
        try:
            if session['username'] is False:
                flash('You must login first!')
                return redirect(url_for('module_employee.login'))
            return f(*args, **kwargs)
        except KeyError:
            flash('Your session is timeout!')
            return redirect(url_for('module_employee.login'))
return wrap

klo bisa ini di taruh di model...

@ghost ghost changed the title file init Advice for placing login_required in the better directory Mar 15, 2017
@ghost
Copy link

ghost commented Mar 15, 2017

Menurut saya login_required jangan ditempatkan di model, karena model seharusnya hanya berisi operasi-operasi yang berhubungan dengan database.

Setelah saya mempelajari flask project structure dari google, saya mendapatkan ini http://flask.pocoo.org/docs/0.12/patterns/viewdecorators/ . Bagaimana kalau saya membuat folder lagi bernama views yang nanti akan berisi helper atau fungsi pembantu yang berhubungan di bagian view, termasuk login_required ini?.

Jadi nanti foldernya seperti ini

-- forms
-- models
-- views
-- statics
-- templates

ghost pushed a commit that referenced this issue Mar 15, 2017
@ghost ghost changed the title Advice for placing login_required in the better directory Advice for placing login_required in better directory Mar 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant