示例#1
0
文件: base.py 项目: fdgonthier/kas
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()
示例#2
0
 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/')
示例#3
0
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()
示例#4
0
    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')
示例#5
0
    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')
示例#6
0
 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))
示例#7
0
 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"))
示例#8
0
 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"))
示例#9
0
 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("/")
示例#10
0
 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/')
示例#11
0
 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))
示例#12
0
 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"))
示例#13
0
 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'))
示例#14
0
 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/')
示例#15
0
文件: twapi.py 项目: pudo/tweetvote
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
示例#16
0
文件: accounts.py 项目: Pylons/kai
 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'))
示例#17
0
 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/')
示例#18
0
 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/')
示例#19
0
 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/')
示例#20
0
 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))
示例#21
0
文件: accounts.py 项目: aureg/baruwa2
 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))
示例#22
0
 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/')
示例#23
0
 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/')
示例#24
0
    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'))
示例#25
0
    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'))
        
示例#26
0
	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)
示例#27
0
 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()
示例#28
0
 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()
示例#29
0
 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()
示例#30
0
文件: account.py 项目: teknikqa/f1
 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()
示例#31
0
 def index(self):
     session.clear()
     session.save()
     redirect(url('index'))
示例#32
0
def signout_user(user):
    user_log.info("logged out")
    session.clear()
    cookie_delete("logged_in")
示例#33
0
 def logout(self):
     session.clear()
     session.save()
     redirect(url('/'))
示例#34
0
 def logout(self):
     session.clear()
     session['flash'] = u"Вы вышли из системы"
     session.save()
     redirect_to(h.url_for(controller="main", action="index", id=None))
示例#35
0
 def logout(self):
     session.clear()
     session.save()
     redirect(url(controller='index', action='index'))
示例#36
0
def logout():

    session.clear()
    session.save()
示例#37
0
文件: account.py 项目: howarth/mypoke
 def logout(self):
     session.clear()
     session.save()
     return redirect_to('/')
示例#38
0
 def logout(self):
     session.clear()
     session.save()
     redirect(url(controller="auth", action="logout"))
示例#39
0
 def logout(self):
     session.clear()
     session.save()
     return render('/login.mako')
示例#40
0
文件: users.py 项目: Python3pkg/DARE
 def logout(self):
     session.clear()
     session.save()
     redirect(url('/'))
示例#41
0
文件: auth.py 项目: dyno/doorkeeper
 def logout(self):
     session.clear()
     session.save()
     return render('/login.mako')
示例#42
0
文件: Login.py 项目: kblin/GSoC-SWAT
 def logout(self):
     # Clear all values in the session associated with the client
     session.clear()
     session.save()
     return json.dumps(self.successOK)
示例#43
0
文件: auth.py 项目: Nullicopter/tethr
def logout():
    
    session.clear()
    session.save()
示例#44
0
def signout():
    session.clear()
    session.save()