-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement #1, move login_required to views
- Loading branch information
dwi purnomo
committed
Mar 15, 2017
1 parent
0343a79
commit 5d4ec72
Showing
3 changed files
with
22 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .authentication import login_required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from functools import wraps | ||
from flask import flash, url_for | ||
from openedoo.core.libs import session, redirect | ||
|
||
|
||
def login_required(f): | ||
@wraps(f) | ||
def wrap(*args, **kwargs): | ||
"""Checks user is logged in or not in the session""" | ||
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 |