Beispiel #1
0
    def get(self, *args, **kwargs):
        '''
		A user logs in with levr using an email or alias, and a password
		'''
        try:
            #RESTRICTED
            logging.debug('LOGIN LEVR\n\n\n')
            logging.debug(kwargs)

            email_or_owner = kwargs.get('email_or_owner')
            pw = kwargs.get('pw')
            pw = enc.encrypt_password(pw)

            #check both email and password

            r_email = levr.Customer.gql('WHERE email = :1 AND pw=:2',
                                        email_or_owner, pw).get()
            r_alias = levr.Customer.gql('WHERE alias = :1 AND pw=:2',
                                        email_or_owner, pw).get()
            if r_email:
                #match based on email
                existing_user = r_email
            elif r_alias:
                #match based on alias
                existing_user = r_alias
            else:
                api_utils.send_error(self, 'Authentication failed.')
                return

            #create or refresh the alias
            existing_user = levr.build_display_name(existing_user)

            #===================================================================
            # Spoof Ninja Activity!
            #===================================================================

            data = api_utils.SpoofUndeadNinjaActivity(existing_user).run()
            logging.debug(levr.log_dict(data))
            #set last login
            existing_user = data['user']
            #still here? update last login by putting
            existing_user.put()

            #package user, private setting, send token
            response = {
                'user':
                api_utils.package_user(existing_user, True, send_token=True)
            }

            api_utils.send_response(self, response, existing_user)
        except:
            levr.log_error()
            api_utils.send_error(self, 'Server Error')
Beispiel #2
0
	def get(self,*args,**kwargs):
		'''
		A user logs in with levr using an email or alias, and a password
		'''
		try:
			#RESTRICTED
			logging.debug('LOGIN LEVR\n\n\n')
			logging.debug(kwargs)
			
			email_or_owner = kwargs.get('email_or_owner')
			pw = kwargs.get('pw')
			pw = enc.encrypt_password(pw)
			
			
			#check both email and password
			
			r_email = levr.Customer.gql('WHERE email = :1 AND pw=:2',email_or_owner,pw).get()
			r_alias  = levr.Customer.gql('WHERE alias = :1 AND pw=:2',email_or_owner,pw).get()
			if r_email:
				#match based on email
				existing_user = r_email
			elif r_alias:
				#match based on alias
				existing_user = r_alias
			else:
				api_utils.send_error(self,'Authentication failed.')
				return
			
			#create or refresh the alias
			existing_user = levr.build_display_name(existing_user)
			
			#===================================================================
			# Spoof Ninja Activity!
			#===================================================================
			
			data = api_utils.SpoofUndeadNinjaActivity(existing_user).run()
			logging.debug(levr.log_dict(data))
			#set last login
			existing_user = data['user']
			#still here? update last login by putting
			existing_user.put()
			
			#package user, private setting, send token
			response = {'user':api_utils.package_user(existing_user,True,send_token=True)}
			
			api_utils.send_response(self,response,existing_user)
		except:
			levr.log_error()
			api_utils.send_error(self,'Server Error')
Beispiel #3
0
	def post(self,*args,**kwargs):
		#RESTRICTED
		try:
			logging.debug(kwargs)
			email = kwargs.get('email',None)
			alias = kwargs.get('alias',None)
			pw = kwargs.get('pw',None)
			
			'''Check availability of username+pass, create and login if not taken'''
			#check availabilities
			r_email = levr.Customer.gql('WHERE email = :1',email).get()
			r_alias  = levr.Customer.gql('WHERE alias = :1',alias).get()
			
			#if taken, send error
			if r_email:
				api_utils.send_error(self,'That email is already registered.')
				return
			if r_alias:
				api_utils.send_error(self,'That alias is already registered.')
				return
			
			#still here? create a customer, then.
			user = levr.create_new_user(
									email=email,
									alias=alias,
									pw=enc.encrypt_password(pw))
			#put and reply
			
			#create or refresh the alias
			user = levr.build_display_name(user)
			
			try:
				levr.text_notify(user.display_name+' from Levr!')
			except:
				levr.log_error()
			
			
			#put and reply
			user.put()
			
			
			response = {'user':api_utils.package_user(user,True,send_token=True)}
			api_utils.send_response(self,response,user)
		except:
			levr.log_error()
			api_utils.send_error(self,'Server Error')
Beispiel #4
0
    def post(self, *args, **kwargs):
        #RESTRICTED
        try:
            logging.debug(kwargs)
            email = kwargs.get('email', None)
            alias = kwargs.get('alias', None)
            pw = kwargs.get('pw', None)
            '''Check availability of username+pass, create and login if not taken'''
            #check availabilities
            r_email = levr.Customer.gql('WHERE email = :1', email).get()
            r_alias = levr.Customer.gql('WHERE alias = :1', alias).get()

            #if taken, send error
            if r_email:
                api_utils.send_error(self, 'That email is already registered.')
                return
            if r_alias:
                api_utils.send_error(self, 'That alias is already registered.')
                return

            #still here? create a customer, then.
            user = levr.create_new_user(email=email,
                                        alias=alias,
                                        pw=enc.encrypt_password(pw))
            #put and reply

            #create or refresh the alias
            user = levr.build_display_name(user)

            try:
                levr.text_notify(user.display_name + ' from Levr!')
            except:
                levr.log_error()

            #put and reply
            user.put()

            response = {
                'user': api_utils.package_user(user, True, send_token=True)
            }
            api_utils.send_response(self, response, user)
        except:
            levr.log_error()
            api_utils.send_error(self, 'Server Error')