def password_reset(pinlist, otp): reset_status = False reset_response = None #On pass reset first we check for otp #If not required none = none, otherwhise sent val has to match stored one if otp == self.otp: #If otp is ok we check for elapsed time to be < 3 mins elapsed_time = (datetime.now() - self.pass_reset_time).total_seconds() if elapsed_time < 180: #If received pins equal expected pins, check for values via reset_password func if all(int(key) in self.pins_check for key in pinlist): reset_response, reset_status = reset_password( self.pins_user_uname, self.pins_user_uid, pinlist) else: reset_response = 'Received pins set differs from expected one. Password reset denied' else: reset_response = 'Pincard 3 minutes reset time has expired. Password reset denied' else: reset_response = 'Sent OTP doesn\'t match. Password reset denied' self.emit( 'pincardManager:passresetresponse', { 'key': 'pincardManager:passresetresponse', 'response': reset_response, 'status': reset_status })
def post(self, request, command, user): with self._handle_exception(request): if (command == 'create'): response_data = save_pincard(user) logger.debug('Created new pincard for user with ' 'uid ({}).'.format(user)) if (command == 'reset'): uid = request.data.get('uid') pinlist = request.data.get('pinlist') reset_response, reset_status = reset_password( user, uid, pinlist) response_data = { 'response': reset_response, 'status': reset_status } logger.debug('Received password reset request for ' 'user ({}).'.format(user)) return Response(response_data) e_msg = ('Unsupported command ({}). Valid commands are ' 'create, reset.').format(command) handle_exception(Exception(e_msg), request)
def post(self, request, command, user): with self._handle_exception(request): if (command == 'create'): response_data = save_pincard(user) logger.debug('Created new pincard for user with uid %s' % user) if (command == 'reset'): uid = request.data.get('uid') pinlist = request.data.get('pinlist') reset_response, reset_status = reset_password(user, uid, pinlist) response_data = {'response': reset_response, 'status': reset_status} logger.debug('Received password reset request for user %s' % user) return Response(response_data) e_msg = ('Unsupported command(%s). Valid commands are create, reset' % command) handle_exception(Exception(e_msg), request)
def post(self, request, command, user): with self._handle_exception(request): if command == "create": response_data = save_pincard(user) logger.debug("Created new pincard for user with uid ({}).".format(user)) if command == "reset": uid = request.data.get("uid") pinlist = request.data.get("pinlist") reset_response, reset_status = reset_password(user, uid, pinlist) response_data = {"response": reset_response, "status": reset_status} logger.debug( "Received password reset request for user ({}).".format(user) ) return Response(response_data) e_msg = ("Unsupported command ({}). Valid commands are create, reset.").format( command ) handle_exception(Exception(e_msg), request)
def password_reset(pinlist, otp): reset_status = False reset_response = None #On pass reset first we check for otp #If not required none = none, otherwhise sent val has to match stored one if otp == self.otp: #If otp is ok we check for elapsed time to be < 3 mins elapsed_time = (datetime.now()-self.pass_reset_time).total_seconds() if elapsed_time < 180: #If received pins equal expected pins, check for values via reset_password func if all(int(key) in self.pins_check for key in pinlist): reset_response, reset_status = reset_password(self.pins_user_uname, self.pins_user_uid, pinlist) else: reset_response = 'Received pins set differs from expected one. Password reset denied' else: reset_response = 'Pincard 3 minutes reset time has expired. Password reset denied' else: reset_response = 'Sent OTP doesn\'t match. Password reset denied' self.emit('pincardManager:passresetresponse', {'key': 'pincardManager:passresetresponse', 'response': reset_response, 'status': reset_status})