def _check_auth(*args,**kwargs): sess = Session(bottle.request,bottle.response) if not sess.is_new(): user = User.find_by_id(sess['id']) if user: return handler(user,*args,**kwargs) return handler(None,*args,**kwargs)
def auth(*args,**kwargs): session = Session(bottle.request,bottle.response) if not session.is_new(): user = User.find_by_id(session['id']) if user: return func(user,*args,**kwargs) bottle.redirect('/login')
def _check_auth(*args, **kwargs): sess = Session(bottle.request, bottle.response) if not sess.is_new(): user = User.find_by_id(sess['id']) if user: return handler(user, *args, **kwargs) bottle.redirect('/login')
def sign_up(): if 'name' in bottle.request.POST and 'password' in bottle.request.POST: name = bottle.request.POST['name'] if name not in reserved_usernames.split(): password = bottle.request.POST['password'] attributes = {} if 'firstName' in bottle.request.POST: attributes['firstName'] = bottle.request.POST['firstName'] if 'lastName' in bottle.request.POST: attributes['lastName'] = bottle.request.POST['lastName'] if 'greeting' in bottle.request.POST: attributes['greeting'] = bottle.request.POST['greeting'] user = User.create(name, password, attributes) if user: sess = Session(bottle.request, bottle.response) sess['id'] = user.id sess.save() bottle.redirect('/home') return bottle.template('login', page='login', error_login=False, error_signup=True, logged=False)
def sign_up(): if 'name' in bottle.request.POST and 'password' in bottle.request.POST: name= bottle.request.POST['name'] if name not in reserved_usernames.split(): password = bottle.request.POST['password'] user = User.create(name,password) if user: sess = Session(bottle.request,bottle.response) sess['id'] = user.id sess.save() bottle.redirect('/home') return bottle.template('login',page='login',error_login=False,error_signup=True,logged=False)
def login(): if 'name' in bottle.request.POST and 'password' in bottle.request.POST: name = bottle.request.POST['name'] password = bottle.request.POST['password'] user = User.find_by_username(name) if user and user.password == settings.SALT + password: sess=Session(bottle.request,bottle.response) sess['id'] = user.id sess.save() bottle.redirect('/home') return bottle.template('login',page='login',error_login=True,error_signup=False,logged=False)
def login(): if 'name' in bottle.request.POST and 'password' in bottle.request.POST: name = bottle.request.POST['name'] password = bottle.request.POST['password'] user = User.find_by_username(name) if user and user.password == settings.SALT + password: sess = Session(bottle.request, bottle.response) sess['id'] = user.id sess.save() bottle.redirect('/home') return bottle.template('login', page='login', error_login=True, error_signup=False, logged=False)
def logged_in_user(): sess = Session(bottle.request,bottle.response) if not sess.is_new(): return User.find_by_id(sess['id']) return None
def logout(): sess = Session(bottle.request,bottle.response) sess.invalidate() bottle.redirect('/')
def logged_in_user(): sess = Session(bottle.request, bottle.response) if not sess.is_new(): return User.find_by_id(sess['id']) return None
def logout(): sess = Session(bottle.request, bottle.response) sess.invalidate() bottle.redirect('/')