def init_session(ws, reinit=False): from kanp import KANP_MINOR if reinit: log.debug("Re-initializing session.") # Re-init session. session.clear() # Re-init KWMO permissions object. c.perms = KWMOPermissions() else: log.debug("Initializing session.") # Set session default variables. session['version'] = 1 session['workspace_id'] = ws.id if ws.public: session['mode'] = MODE_PUBWS else: session['mode'] = MODE_WS if ws.compat_v2: session['kanp_minor'] = 2 else: session['kanp_minor'] = KANP_MINOR session['user'] = None session['secure'] = bool(c.workspace.secured) session['last_perm_check_id'] = ws.last_perm_check_id session['last_evt_ws_id'] = ws.evt_ws_id session['last_evt_user_id'] = ws.evt_user_id session['initialized'] = True session['perms'] = c.perms.to_dict() session.save()
def addIssue(self): memID = request.params['memberid'] bkID = request.params['bookid'] mem = Session.query(Members).filter_by(memberID=memID).first() member_allowance = Session.query(Issues).all() nameList = [] for i in member_allowance: nameList.append(i.memberID) d = {} for i in set(nameList): d[i] = nameList.count(i) if d.get(int(memID), 1) > 2: session['flash'] = 'That member may not take out any more books.\ Maximum allowance of 3 reached.' session.save() #self.index() else: bk = Session.query(Books).filter_by(bookID=bkID).first() bk.status = False Session.add(bk) Session.commit() issueDate = datetime.date.today() dueDate = issueDate + datetime.timedelta(days=14) returned = False issue_details = Issues(mem.memberID, bk.bookID, issueDate, dueDate, returned) Session.add(issue_details) Session.commit() session.clear() session['flash'] = 'Issue successfully added' session.save() redirect('/issues/')
def submit(self): """ Verify username and password """ auth_passed = False # Both fields filled? username = request.params.get('username') password = request.params.get('password') #for auth in cfg.auth: # if auth(username=username, password=password, config=cfg): if username == "test": auth_passed = True # break # Mark user as logged in if auth_passed: session['user'] = username log.info(u"User %s logged in" % session['user']) session.save() # Send user back to the page he originally wanted to get to if session.get('path_before_login'): redirect(url(session['path_before_login'])) else: # if previous target is unknown just send the user to a welcome page redirect('/') else: log.error("User %s login failed from host [%s]" % ( username, request.remote_addr)) session.clear() session.save() return render('/login.mako')
def submit(self): """ Verify username and password """ auth_passed = False # Both fields filled? username = request.params.get('username') password = request.params.get('password') #for auth in cfg.auth: # if auth(username=username, password=password, config=cfg): if username == "test": auth_passed = True # break # Mark user as logged in if auth_passed: session['user'] = username log.info(u"User %s logged in" % session['user']) session.save() # Send user back to the page he originally wanted to get to if session.get('path_before_login'): redirect(url(session['path_before_login'])) else: # if previous target is unknown just send the user to a welcome page redirect('/') else: log.error("User %s login failed from host [%s]" % (username, request.remote_addr)) session.clear() session.save() return render('/login.mako')
def loggedout(self): "Logged out page" session.clear() session.save() came_from = (unquote(str(request.params.get('came_from', ''))) or url('/accounts/login')) redirect(url(came_from))
def logout(self): del session['user'] if 'current_trip' in session: del session['current_trip'] session.clear() session.save() tripsharing.cancel() redirect(h.url_for(controller='splash', action="index"))
def logout(self): del session['user'] if 'current_trip' in session: del session['current_trip'] session.clear() session.save() tripsharing.cancel() redirect(h.url_for(controller='splash',action="index"))
def logout(self): if session.get("email"): session.clear() session.save() if request.cookies.get("email"): response.delete_cookie("email") response.delete_cookie("password") redirect("/")
def deleteBook(self): bk_id = request.params['bkID'] bk_details = self.book_q.filter_by(bookID=bk_id).first() Session.delete(bk_details) Session.commit() session.clear() session['flash'] = 'Book successfully deleted.' session.save() redirect('/books/')
def loggedout(self): "Logged out page" session.clear() if 'theme' in session: del session['theme'] session.save() came_from = (unquote(str(request.params.get('came_from', ''))) or url('/accounts/login')) redirect(url(came_from))
def dologin(self): session.clear() qloginer = meta.Session.query(model.Person) person = qloginer.filter_by(login=self.form_result['login']).first() # Загрузка информации о человеке и его правах доступа h.refresh_account(person.id) # Велкам! session['flash'] = u"Вы успешно вошли в систему" session.save() redirect_to(h.url_for(controller="main", action="index"))
def __before__(self): if self.requires_auth and not session.get('logged_in'): if session.get('after_login') is None: session.clear() if url.current() != url(controller='auth/login', action='index'): session['after_login'] = url.current() else: session['after_login'] = url('/') session.save() redirect(url(controller='auth/login', action='index'))
def addBook(self): title = self.form_result['title'] author = self.form_result['author'] status = True bk_details = Books(title, author, status) Session.add(bk_details) Session.commit() session.clear() session['flash'] = 'Successfully added new book.' session.save() redirect('/books/')
def set_credentials(username, password): session['username'] = username session['password'] = password api = create_api() if api: session['user_id'] = api.GetUser(api._username).id else: session.clear() session.save() return api
def logout(self): c.user.session_id = None c.user.store(self.db) session.clear() session.expire() session.save() redir = request.GET.get('redir') success_flash('You have logged out of your session') if redir: redirect(url(str(redir))) else: redirect(url('home'))
def addMember(self): name = self.form_result['name'] address = self.form_result['address'] suburb = self.form_result['suburb'] city = self.form_result['city'] mem_details = Members(name, address, suburb, city) Session.add(mem_details) Session.commit() session.clear() session['flash'] = 'New member successfully added.' session.save() redirect('/members/')
def editBook(self): bk_id = request.params['id'] bk_details = self.book_q.filter_by(bookID=bk_id).first() bk_details.title = self.form_result['title'] bk_details.author = self.form_result['author'] #bk_details.status = request.params['status'] Session.add(bk_details) Session.commit() session.clear() session['flash'] = 'Book successfully edited.' session.save() redirect('/books/')
def editMember(self): mem_id = request.params['id'] mem_details = self.member_q.filter_by(memberID=mem_id).first() mem_details.name = self.form_result['name'] mem_details.address = self.form_result['address'] mem_details.suburb = self.form_result['suburb'] mem_details.city = self.form_result['city'] Session.add(mem_details) Session.commit() session.clear() session['flash'] = 'Member successfully edited.' session.save() redirect('/members/')
def loggedout(self): "Logged out page" # response.delete_cookie('baruwacsrf') if 'lang' in session: lang = session['lang'] session.clear() if 'lang' in locals(): session['lang'] = lang session.save() #flash(_('You have been logged out !')) came_from = (unquote(str(request.params.get('came_from', ''))) or url('/accounts/login/')) redirect(url(came_from))
def deleteIssue(self): is_id = request.params['issueID'] is_details = self.issue_q.filter_by(issueID=is_id).first() bk = Session.query(Books).filter_by(bookID=is_details.bookID).first() bk.status = True Session.add(bk) Session.commit() Session.delete(is_details) Session.commit() session.clear() session['flash'] = 'Issue successfully returned.' session.save() redirect('/issues/')
def editIssue(self): is_id = request.params['id'] is_details = self.issue_q.filter_by(issueID=is_id).first() is_details.memberID = request.params['memberID'] is_details.bookID = request.params['bookID'] i = datetime.datetime.strptime(request.params['issueDate'], '%Y-%m-%d') is_details.issueDate = i print is_details.issueDate, '*' * 500 d = datetime.datetime.strptime(request.params['dueDate'], '%Y-%m-%d') is_details.dueDate = d Session.add(is_details) Session.commit() session.clear() session['flash'] = 'Issue successfully edited.' session.save() redirect('/issues/')
def signout(self): user = session.get('user') or request.environ.get('REMOTE_USER') if user: log.info("%s signed out." % user) # Hack to confirm logout of user. session.clear() session.save() if request.environ.has_key('REMOTE_USER'): del request.environ['REMOTE_USER'] # The actual removal of the AuthKit cookie occurs when the response passes # through the AuthKit middleware, we simply need to display a page # confirming the user is signed out session.invalidate() redirect(url(controller='homepage', action='index'))
def post_logout(self): flash = None basket = None if session.has_key('flash'): flash = session['flash'] if session.has_key('basket'): basket = session['basket'] session.clear() if flash: session['flash']=flash if basket: session['basket'] = basket session.save() redirect(url(controller='home', action='index'))
def test_create_user(self): session['auth_type'] = 'facebook' session['auth_oid'] = '1234567890' session.save() res = create_user(session) self.assertNotEquals(res.id, None) self.assertEquals(res.name, None) self.assertEquals(res.type, 9) self.assertEquals(res.profile, None) self.assertEquals(res.open_id, None) self.assertEquals(res.fb_id, '1234567890') self.assertEquals(res.twitter_id, None) session.clear() session['auth_type'] = 'twitter' session['auth_oid'] = '1234567890' session.save() res = create_user(session) self.assertNotEquals(res.id, None) self.assertEquals(res.name, None) self.assertEquals(res.type, 9) self.assertEquals(res.profile, None) self.assertEquals(res.open_id, None) self.assertEquals(res.twitter_id, '1234567890') self.assertEquals(res.fb_id, None) session.clear() session['auth_type'] = 'openid' session['auth_oid'] = 'http://user.example.com' session.save() res = create_user(session) self.assertNotEquals(res.id, None) self.assertEquals(res.name, None) self.assertEquals(res.type, 9) self.assertEquals(res.profile, None) self.assertEquals(res.open_id, 'http://user.example.com') self.assertEquals(res.twitter_id, None) self.assertEquals(res.fb_id, None)
def signout(self): domain = request.params.get('domain') username = request.params.get('username') userid = request.params.get('userid') if domain and username or userid: try: keys = [k for k in session.get('account_keys', '').split(',') if k] rem_keys = keys[:] for k in keys: acct = session[k] if acct['domain']==domain and \ (not username or acct['username']==username) and \ (not userid or acct['userid']==userid): session.pop(k) rem_keys.remove(k) session['account_keys'] = ','.join(rem_keys) except: log.exception('failed to signout from domain %s', domain) session.clear() else: session.clear() session.save()
def signout(self): domain = request.params.get('domain') username = request.params.get('username') userid = request.params.get('userid') if domain and username or userid: try: keys = [k for k in session.get('account_keys', '').split(',') if k] for k in keys: session.pop(k) _and = [Account.domain==domain] if username: _and.append(Account.username==username) if userid: _and.append(Account.userid==userid) accts = Session.query(Account).filter(Account.key.in_(keys)).filter(not_(and_(*_and))).all() session['account_keys'] = ','.join([a.key for a in accts]) for a in accts: session[a.key] = a.to_dict() except: session.clear() else: session.clear() session.save()
def signout(self): domain = request.params.get('domain') username = request.params.get('username') userid = request.params.get('userid') if domain and username or userid: try: keys = [ k for k in session.get('account_keys', '').split(',') if k ] rem_keys = keys[:] for k in keys: acct = session[k] if acct['domain']==domain and \ (not username or acct['username']==username) and \ (not userid or acct['userid']==userid): session.pop(k) rem_keys.remove(k) session['account_keys'] = ','.join(rem_keys) except: log.exception('failed to signout from domain %s', domain) session.clear() else: session.clear() session.save()
def signout(self): domain = request.params.get("domain") username = request.params.get("username") userid = request.params.get("userid") if domain and username or userid: try: keys = [k for k in session.get("account_keys", "").split(",") if k] rem_keys = keys[:] for k in keys: acct = session[k] if ( acct["domain"] == domain and (not username or acct["username"] == username) and (not userid or acct["userid"] == userid) ): session.pop(k) rem_keys.remove(k) session["account_keys"] = ",".join(rem_keys) except: log.exception("failed to signout from domain %s", domain) session.clear() else: session.clear() session.save()
def index(self): session.clear() session.save() redirect(url('index'))
def signout_user(user): user_log.info("logged out") session.clear() cookie_delete("logged_in")
def logout(self): session.clear() session.save() redirect(url('/'))
def logout(self): session.clear() session['flash'] = u"Вы вышли из системы" session.save() redirect_to(h.url_for(controller="main", action="index", id=None))
def logout(self): session.clear() session.save() redirect(url(controller='index', action='index'))
def logout(): session.clear() session.save()
def logout(self): session.clear() session.save() return redirect_to('/')
def logout(self): session.clear() session.save() redirect(url(controller="auth", action="logout"))
def logout(self): session.clear() session.save() return render('/login.mako')
def logout(self): # Clear all values in the session associated with the client session.clear() session.save() return json.dumps(self.successOK)
def signout(): session.clear() session.save()