当前位置: 首页>>代码示例>>Python>>正文


Python auth.get_auth函数代码示例

本文整理汇总了Python中webapp2_extras.auth.get_auth函数的典型用法代码示例。如果您正苦于以下问题:Python get_auth函数的具体用法?Python get_auth怎么用?Python get_auth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了get_auth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get

 def get(self):
     template_values = {
             'title': 'Login page',
             'login': False
         }
     if auth.get_auth().get_user_by_session():
         user_id = auth.get_auth().get_user_by_session()['user_id']
         user = User.get_by_id(user_id)
         userURI = user.name if user.name else user_id
         name = user.name if user.name else user.email_address
         if user:
             template_values = {
                 'title': 'Hi there, {}'.format(name),
                 'login': True,
                 'name': userURI,
                 'messages': ''
             }
         if self.request.path == '/':
             self.redirect('/{}'.format(user_id))
         if self.request.path == '/logout':
             auth.get_auth().unset_session()
             self.redirect('/')
             logging.info('Logout bye bye...')
         if self.request.path == '/profile':
             template_values['page'] = 'profile'
             profile = ProfileHandler()
             profile.drawProfilePage()
     template = JINJA_ENVIRONMENT.get_template('_layout.html')
     self.response.write(template.render(template_values))
开发者ID:MarkoSh,项目名称:NextImage,代码行数:29,代码来源:main.py


示例2: logout

 def logout(self):
     get_auth().unset_session()
     
     next = self.request.params.get('next', None)
     if not next:
         next = settings.get('db_login')['logout_dest_url']
     return self.redirect(next)
开发者ID:ksdtech,项目名称:gae-conferences,代码行数:7,代码来源:sessions.py


示例3: post_logout

			def post_logout(self):
				auth.get_auth().unset_session()

				# User is logged out, let's try redirecting to login page
				try:
					self.redirect(self.logout_result)
				except (AttributeError, KeyError), e:
					return "User is logged out"
开发者ID:Diddit,项目名称:diddit,代码行数:8,代码来源:gaut.py


示例4: post

    def post(self):
        username = self.request.POST.get('username', None)
        password = self.request.POST.get('password', None)

        try:
            auth.get_auth().get_user_by_password(username, password)
        except Exception, e:
            logging.warning(e)
开发者ID:michaelore,项目名称:cdc2012,代码行数:8,代码来源:main.py


示例5: auth

    def auth(self):
        """Extract an Auth object from the request object.

        Returns:
            An Auth object (webapp2_extras.auth.Auth) containing
            the authorization of the current user.
        """
        print auth.get_auth(request=self.request).get_user_by_session()
        return auth.get_auth(request=self.request)
开发者ID:fractal1729,项目名称:emcc-website,代码行数:9,代码来源:BaseHandler.py


示例6: post

 def post(self):
     username = self.request.get('username')
     password = self.request.get('password')
     try:
         auth.get_auth().get_user_by_password(username, password,
                                              remember=True, save_session=True)
         return self.redirect(self.uri_for('home'))
     except auth.AuthError as e:
         logging.info('Login failed for user %s because of %s', username, type(e))
         return self._serve_page(True)
开发者ID:gsakkis,项目名称:webapp2-user-accounts,代码行数:10,代码来源:main.py


示例7: insert_details

def insert_details(context):
    try:
        current_session = auth.get_auth().get_user_by_session()
        new_user_object = auth.get_auth().store.user_model.get_by_auth_token(current_session['user_id'], current_session['token'])[0]
        username = new_user_object.auth_ids[0]
        old_user_object = models.Account.all().filter('username =', username).fetch(1)[0].__dict__['_entity']

        context['username'] = old_user_object['username']
        context['is_admin'] = old_user_object['is_admin']
        context['is_employee'] = old_user_object['is_employee']
    except Exception, e:
        logging.warning(e)
开发者ID:michaelore,项目名称:cdc2012,代码行数:12,代码来源:main.py


示例8: UpdateGcmGroup

def UpdateGcmGroup(self,instanttype,ohurl):
	uniqueid = self.request.get("uniqueid")
	bname = self.request.get("bname")
	message = self.request.get("message")
	atplace = self.request.get("atplace")
        bid = ''        
	timestamp = datetime.datetime.now()
	userid = self.user_id
	userDetails = self.current_user
	group_query = GroupData.query(GroupData.uniqueid == uniqueid)	
	groups = group_query.fetch(1) 
	registration_ids = []
        frienduserids = []
	for group in groups:
            bid = group.bid
            if group.userid != self.user_id:
                l_auth = auth.get_auth()
                userData = l_auth.store.user_model.get_by_id (group.userid)
                registration_ids.append(userData.instants.gcm_regid)                            
	    instants = group.instants            
	    if len(instants) > 20:
		del instants[-1]
	    instant = InstantMesg(message = message,atplace = atplace,userid=self.user_id,timestamp = timestamp,instanttype = instanttype,ohid = ohurl,gcmtype='group',uniqueid=uniqueid)
	    instants.append(instant)
	    group.instants = instants
            friends = group.friends
            for friend in friends:
                if friend.state == 'in':
                    frienduserids.append(friend.userid)
                    if self.user_id != friend.userid:
                        l_auth = auth.get_auth()
                        userData = l_auth.store.user_model.get_by_id (friend.userid)
                        registration_ids.append(userData.instants.gcm_regid)            
	    group.put()

	secs = calendar.timegm(timestamp.timetuple())
	logging.info("%s" %frienduserids)
	logging.info("%s" %registration_ids)
	if len(registration_ids) == 0:
	    self.response.write("")
	    return
	Bodyfields = {
	      "data": {"live":message,"username":userDetails.name,"bid":bid,"bname":bname,"atplace":atplace,"timestamp":secs,"instanttype":instanttype,'ohurl':ohurl,'uniqueid':uniqueid},
	      "registration_ids": registration_ids
	     }
	result = urlfetch.fetch(url="https://android.googleapis.com/gcm/send",
			payload=json.dumps(Bodyfields),
			method=urlfetch.POST,
			headers={'Content-Type': 'application/json','Authorization': 'key=AIzaSyBNnXeISW8-KfETBKE-r0ASytx4WyC6NTk'})
	#self.response.out.write('Server response, status: ' + result.content )
        return result
开发者ID:thejasvibhat,项目名称:smashed,代码行数:51,代码来源:gcm.py


示例9: post

 def post(self):
     if self.request.get('login'):
         template_values = {
             'title': 'Login page',
             'login': False
         }
         login = self.request.get('login')
         password = self.request.get('password')
         if "checkname" in self.request.path:
             logging.info('Checking name {}...'.format(login))
             # TODO проверка доступности логина, вернуть джисоном результат
         if self.request.get('sigbtn'):
             logging.info('Registering user {}...'.format(login))
             if "@" in login and len(password) > 6:
                 unique_properties = ['email_address']
                 user = User.create_user(login, unique_properties,
                                         email_address=login,
                                         password_raw=password,
                                         verified=False)
                 if not user[0]:
                     template_values = {
                         'title': ERRORMSG_TRYLOGIN,
                         'notify': ERRORMSG_TRYLOGIN,
                         'login': False
                     }
                     logging.info('Unable to create user {}, duplicating key {}'.format(login, user[1]))
                 else:
                     logging.info('6sfull creating user {}'.format(login))
                     user_id = user[1].get_id()
                     auth.get_auth().set_session(auth.get_auth().store.user_to_dict(user[1]))
                     self.redirect('/{}'.format(user_id))
         if self.request.get('logbtn'):
             logging.info('Logging as {}...'.format(login))
             try:
                 user_id = auth.get_auth().get_user_by_password(login, password, remember=True, save_session=True,
                                                                silent=False)['user_id']
                 self.session_store.save_sessions(self.response)
                 logging.info('6sfull logged user {} '.format(login))
                 self.redirect('/{}'.format(user_id))
             except (InvalidPasswordError, InvalidAuthIdError) as e:
                 template_values = {
                         'title': ERRORMSG_INVLOGIN,
                         'notify': ERRORMSG_INVLOGIN,
                         'login': False
                     }
                 logging.info("Auth error {}".format(type(e)))
         template = JINJA_ENVIRONMENT.get_template('_layout.html')
         self.response.write(template.render(template_values))
开发者ID:MarkoSh,项目名称:NextImage,代码行数:48,代码来源:main.py


示例10: get

    def get (self):
        fsbid = self.request.get ("fsbid");
        meme_query = UserMemeDb.query(UserMemeDb.fsbid == fsbid)
        oLimit = int(self.request.get("limit", default_value="10"))
        oOffset = int(self.request.get("offset", default_value="0"))
        memes = meme_query.fetch(oLimit,offset=oOffset)
        self.response.write('<memes>')
        for meme in memes:
            l_auth = auth.get_auth()
            userData = l_auth.store.user_model.get_by_id (meme.userid)
            #logging.info(userData)
            self.response.write('<meme>')
            self.response.write('<ts>')
            self.response.write('%s' %meme.date)
            self.response.write('</ts>')			
            self.response.write('<icon>')
            self.response.write('/res/icon/%s' %meme.blobid)
            self.response.write('</icon>')
            self.response.write('<url>')
            self.response.write('/oh/%s' %meme.resid)
            self.response.write('</url>')
            
            self.response.write('<creatorname>')
            self.response.write('%s' %userData.name)
            self.response.write('</creatorname>')

            self.response.write('<creatoravatar>')
            self.response.write('%s' %userData.avatar_url)
            self.response.write('</creatoravatar>')

            self.response.write('</meme>')
        self.response.write('</memes>')         
开发者ID:thejasvibhat,项目名称:smashed,代码行数:32,代码来源:meme.py


示例11: post

    def post(self):
        print self.request.POST

        name = self.request.POST.get('name')
        passw = self.request.POST.get('password')

        if not name or not passw:
            jsonMsg(self.response, 'Missing Required Field')
            self.response.set_status(400, "Missing required field")
            return

        success, user = auth.get_auth().store.user_model.create_user(name, password_raw=passw)

        if not success:
            prefix='Unable to create that user:'

            if 'auth_id' in user:
                jsonMsg(self.response, prefix + " Username Already Taken")
                self.response.set_status(400)
            else:
                jsonMsg(self.response, prefix + " Server Error")
                self.response.set_status(500)
            return

        else:
            print user
            self.response.write(
                json.dumps({"msg": "User Logged In",
                            'userid': user.key.id(),
                            'token': user.create_auth_token(user.key.id())},
                           indent=2
                           ))
            self.response.write("\n")
            self.response.set_status(200)
            return
开发者ID:swanyriver,项目名称:webapp-user-test,代码行数:35,代码来源:main.py


示例12: get

    def get(self, verification_type, user_id, token):
        user, ts = User.get_by_auth_token(int(user_id), token, verification_type)
        if not user:
            logging.info('Could not find any user with id "%s" token "%s"',
                         user_id, token)
            self.abort(404, 'This link has expired')

        # remove token, we don't want users to come back with an old link
        User.delete_auth_token(user.get_id(), token, verification_type)

        # store user data in the session
        auth_obj = auth.get_auth()
        # invalidate current session (if any) and set a new one
        auth_obj.unset_session()
        auth_obj.set_session(auth_obj.store.user_to_dict(user), remember=True)

        if verification_type == 'signup':
            if not user.verified:
                user.verified = True
                user.put()
            return self.display_message('User email address has been verified.')
        elif verification_type == 'reset':
            return self.render_template('resetpassword.html')

        assert False, verification_type
开发者ID:gsakkis,项目名称:webapp2-user-accounts,代码行数:25,代码来源:main.py


示例13: get

    def get(self):
        uniqueid = self.request.get('uniqueid')
        userid = self.user_id
	group_query = GroupData.query(GroupData.uniqueid == uniqueid)	
	groups = group_query.fetch(1) 
        delsuccess = False
        registration_ids = []
	for group in groups:
            if group.userid == userid:
                for friend in group.friends:
                    uid = friend.userid
                    if friend.state == 'in':
                        l_auth = auth.get_auth()
                        userData = l_auth.store.user_model.get_by_id (uid)
                        registration_ids.append(userData.instants.gcm_regid)
                group.key.delete()
                delsuccess = True
	if len(registration_ids) != 0:
	    Bodyfields = {
	      "data":{"instanttype":'delete','uniqueid':uniqueid},
	      "registration_ids": registration_ids
	     }
            result = urlfetch.fetch(url="https://android.googleapis.com/gcm/send",
			payload=json.dumps(Bodyfields),
			method=urlfetch.POST,
			headers={'Content-Type': 'application/json','Authorization': 'key=AIzaSyBNnXeISW8-KfETBKE-r0ASytx4WyC6NTk'})
        if delsuccess == True:
             self.response.write('success')
        else:
             self.response.write('failure')
开发者ID:thejasvibhat,项目名称:smashed,代码行数:30,代码来源:gcm.py


示例14: auth

  def auth(self):
    """
    Shortcut to access the auth instance as a property. Borrowed from:
    http://blog.abahgat.com/2013/01/07/user-authentication-with-webapp2-on-google-app-engine/

    """
    return auth.get_auth()
开发者ID:emma-murray,项目名称:cs496-finalproject,代码行数:7,代码来源:base.py


示例15: get_user

def get_user(a=None):
	if(not a):
		a=auth.get_auth()
	udict=a.get_user_by_session()
	if(udict):
		return User(udict['user_id'])
	return None
开发者ID:Diddit,项目名称:diddit,代码行数:7,代码来源:gaut.py



注:本文中的webapp2_extras.auth.get_auth函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。