Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # skysim/logincheck.py
- from flask import session,request
- import skysimulation
- import skysimulation.user as User
- # User just has some functions for checking username/password combinations and stuff
- class LoginCheck(object):
- REQUIRES_LOGIN = False
- def before_request(self):
- session.permanent = True
- if 'username' in session and 'password' in session:
- result = User.checkLogin(session['username'],session['password'])
- if result > 0:
- self.context['logged_in'] = True
- session['id_user'] = result
- session['logged_in'] = True
- return
- session['logged_in'] = False
- self.context['logged_in'] = False
- if self.REQUIRES_LOGIN:
- pass # TODO redirect to login
- def after_request(self,resp):
- return resp # FIXME not needed anymore
Add Comment
Please, Sign In to add comment