def post(self, request, app_code, mode, pid, rid):
     '''
        This will be a post request to re-send the email with link and token for password reset request.
        @param request: A HttpRequest object
        @param app_code: Application from which request initiated
        @param mode: Reset mode 1, for by own registered mail or 2 for by other alternative mail.
        @param pid: Profile Id of the user.
        @param rid: A Valid Request open ID.
        @return: A response message saying delivered link or not.
     '''
     log.info('[START]- Request Received for re-sending the token mail for the password reset process.');
     
     _email, _alt_email = request.GET.get('em'), request.GET.get('alt');
     #If request is not valid stop the request processing
     if not _email or (mode == '2' and not _alt_email):
         log.info('[END]- Request aborting as the entered details are not correct.');
         dic = {};
         dic['CODE'] = '403';
         dic['message'] = 'Sorry your request can\'t be processed now.';
         return self.handelResponse(request, dic);  
     
     #write logic for the request process, then return the response
     #Get user Agent and IP
     USER_AGENT = UserAgent()
     user_ip, user_agent = USER_AGENT.get_client_ip(request), USER_AGENT.get_browser_agent(request);
     #build temporary response to be handel but latter it needs to be web service call
     res =  self.requestForNewToken(app_code, mode, pid, rid, _email, _alt_email, user_ip, user_agent);
     # process for the service call and return back with the response
     dev_mode = getattr(settings, "SKIP_WEB_CALL", 'n');
     log.info('[END]- Request Completed for the re-send token email for forgot password.');
     if dev_mode == 'y':
         return self.handelResponse(request, self.webMockData());
     
     return self.handelResponse(request, res);
Example #2
0
    def post(self, request, app_code):
        '''
          This will be used when login form will be submitted.
          @param request: HttpRequest for this operation
          @param app_code: Which app made this login request
        '''
        log.info('[START]- Request Received for the Authentication.');
        # First Decide Destination
        destination = request.GET.get('des', getDestinationByAppCode(app_code));
        keepmelogin = '******' if request.POST.get('loggedinFlag') else 'N'
        
        # Get user Agent and IP
        USER_AGENT = UserAgent()
        user_ip, user_agent = USER_AGENT.get_client_ip(request), USER_AGENT.get_browser_agent(request);
        password, user_id = request.POST.get('password', None), request.POST.get('user_id', None);
        # pwdEncApi = EncryptionUtil(self.PASSWORD_KEY);
        # password = pwdEncApi.encryptText(password)
        errors = self.validateForm(user_id, password, user_ip, destination);

        if errors:
            # add Context and return to the page
            errors['app_code'] = app_code;
            errors['des'] = destination;
            log.info('[END]- Aborting Authentication request as user has given invalid data.');
            return self.loginResponseMixIn(request, errors);
             
        # log.info('--->asasa->%s',validate_email(email))
        # forms = {"type": "cookie","client_meta": "assmjhasjhaskashkashk","ip": '127.0.0.1', "prfid": "1234", "authid": "1", "prvauthid": "1", "token": "abcde", "prvtoken": "abcde","lgnid":"1"}
        sr_response = self.authenticate(user_agent, user_ip, user_id, password, keepmelogin);
        log.info('[END]- Authentication Request Completed, taking action based on the response.');
        dev_mode = getattr(settings, "SKIP_WEB_CALL", 'n');
        if dev_mode == 'y':
            return HttpResponse('SucessFully Logged in.');
        
        return self.processResponse(request, sr_response, destination, app_code);
Example #3
0
    def post(self, request, app_code):
        '''
           In case user has forgot the password or his account has been hacked including email account,
           he will key in the email/email he has access or most recent password in case account has been hacked.
           @param request: HttpRequest for this web flow.
           @param app_code: Appcode From which user is tying to access.
           @return: if all the details input by the user is correct then he will be navigate to the change password
                    screen, else he will be stay back at the same page with the error details.
        '''
        log.info(
            '[START]-Requesting for the forgot password process to be started to navigate to the change password page.'
        )
        destination, _reset_option = request.GET.get('des'), request.POST.get(
            'preoption')
        _recent_pwd, _alt_email = '', ''
        if _reset_option == '1' or _reset_option == 1:
            _email = request.POST.get('uimSignedUpEmail')
        elif _reset_option == '2' or _reset_option == 2:
            _email, _alt_email, _recent_pwd = request.POST.get(
                'uimEmail'), request.POST.get(
                    'uimResetEmailAccessTo'), request.POST.get('uimRecentPwd')

        # Get user Agent and IP
        USER_AGENT = UserAgent()
        user_ip, user_agent = USER_AGENT.get_client_ip(
            request), USER_AGENT.get_browser_agent(request)

        # validate the user submitted form
        errors = self.validateForm(_email, _alt_email, _recent_pwd,
                                   _reset_option)
        if errors:
            # add Context and return to the page
            log.info(
                '[END]-As the inputs are not valid asking user to re input the details.'
            )
            return self.stayAtSamePage(
                request,
                self.buildErrorMap(app_code, destination, _reset_option,
                                   errors))

        # process for the service call and return back with the response
        dev_mode = getattr(settings, "SKIP_WEB_CALL", 'n')
        if dev_mode == 'y':
            sr_response = self.buildWebMockData()
        else:
            sr_response = self.forgotPassword(user_agent, user_ip, _email,
                                              _alt_email, _recent_pwd,
                                              _reset_option, destination)

        log.info(
            '[END]-Forgot Password request Completed, processing the response received from web call.'
        )
        return self.processResponse(request, sr_response, destination,
                                    app_code, _reset_option, _email,
                                    _alt_email)
Example #4
0
    def post(self, request, app_code):
        '''
          This will be used when login form will be submitted.
          @param request: HttpRequest for this operation
          @param app_code: Which app made this login request
        '''
        log.info('[START]- Request Received for the Authentication.')
        # First Decide Destination
        destination = request.GET.get('des', getDestinationByAppCode(app_code))
        keepmelogin = '******' if request.POST.get('loggedinFlag') else 'N'

        # Get user Agent and IP
        USER_AGENT = UserAgent()
        user_ip, user_agent = USER_AGENT.get_client_ip(
            request), USER_AGENT.get_browser_agent(request)
        password, user_id = request.POST.get('password',
                                             None), request.POST.get(
                                                 'user_id', None)
        # pwdEncApi = EncryptionUtil(self.PASSWORD_KEY);
        # password = pwdEncApi.encryptText(password)
        errors = self.validateForm(user_id, password, user_ip, destination)

        if errors:
            # add Context and return to the page
            errors['app_code'] = app_code
            errors['des'] = destination
            log.info(
                '[END]- Aborting Authentication request as user has given invalid data.'
            )
            return self.loginResponseMixIn(request, errors)

        # log.info('--->asasa->%s',validate_email(email))
        # forms = {"type": "cookie","client_meta": "assmjhasjhaskashkashk","ip": '127.0.0.1', "prfid": "1234", "authid": "1", "prvauthid": "1", "token": "abcde", "prvtoken": "abcde","lgnid":"1"}
        sr_response = self.authenticate(user_agent, user_ip, user_id, password,
                                        keepmelogin)
        log.info(
            '[END]- Authentication Request Completed, taking action based on the response.'
        )
        dev_mode = getattr(settings, "SKIP_WEB_CALL", 'n')
        if dev_mode == 'y':
            return HttpResponse('SucessFully Logged in.')

        return self.processResponse(request, sr_response, destination,
                                    app_code)
Example #5
0
    def post(self, request, app_code, mode, pid, rid):
        '''
           This will be a post request to re-send the email with link and token for password reset request.
           @param request: A HttpRequest object
           @param app_code: Application from which request intiated
           @param mode: Reset mode 1, for by own registered mail or 2 for by other alternative mail.
           @param pid: Profile Id of the user.
           @param rid: A Valid Request open ID.
           @return: A response message saying delivered link or not.
        '''
        log.info('[START]-Request Received for Change password.');
        destination, _email, _alt_email = request.GET.get('des'), request.GET.get('em'), request.GET.get('aem');
        # If request is not valid stop the request processing
        if not destination or not _email or (mode == '2' and not _alt_email):
            log.error("[END]-Invalid request received for password Change.");
            return self.redirectToLoginPage(app_code, destination);  
        # Get user Agent and IP
        USER_AGENT = UserAgent()
        user_ip, user_agent = USER_AGENT.get_client_ip(request), USER_AGENT.get_browser_agent(request);
        
        # get the form data
        newPassword, confirmPassword, token, source = request.POST.get('newPassword'), request.POST.get('confirmPassword'), request.POST.get('token'), request.POST.get('src');
        useAsNewUidFlag = ''
        if mode == '2':
            useAsNewUidFlag = request.POST.get('useAsNewUidFlag');

        # validate the user submitted form
        errors = self.validateForm(_alt_email, newPassword, confirmPassword, token, source, pid, rid, useAsNewUidFlag, mode, user_ip, destination, app_code);
        if errors:
            # add Context and return to the page
            log.info('[END]- As Validation Failed Returning to correct input in change password screen.')
            return self.restPasswordMixIn(request, self.buildResetPageMap(app_code, destination, _email, _alt_email, mode, pid, rid, token, source, errors));
        
        # process for the service call and return back with the response
        dev_mode = getattr(settings, "SKIP_WEB_CALL", 'n');
        if dev_mode == 'y':
            # Dummy take help latter
            return HttpResponse('Password Successfully changed.');
        else:
            sr_response = self.changePassword(user_agent, user_ip, _email, _alt_email, useAsNewUidFlag, pid, rid, source, app_code, newPassword, mode);
        log.info('[END]-Request completed for the Change Password.');
        return self.processResponse(request, sr_response, destination, app_code, mode, _email, _alt_email);
    def post(self, request, app_code, mode, pid, rid):
        '''
           This will be a post request to re-send the email with link and token for password reset request.
           @param request: A HttpRequest object
           @param app_code: Application from which request initiated
           @param mode: Reset mode 1, for by own registered mail or 2 for by other alternative mail.
           @param pid: Profile Id of the user.
           @param rid: A Valid Request open ID.
           @return: A response message saying delivered link or not.
        '''
        log.info(
            '[START]- Request Received for re-sending the token mail for the password reset process.'
        )

        _email, _alt_email = request.GET.get('em'), request.GET.get('alt')
        #If request is not valid stop the request processing
        if not _email or (mode == '2' and not _alt_email):
            log.info(
                '[END]- Request aborting as the entered details are not correct.'
            )
            dic = {}
            dic['CODE'] = '403'
            dic['message'] = 'Sorry your request can\'t be processed now.'
            return self.handelResponse(request, dic)

        #write logic for the request process, then return the response
        #Get user Agent and IP
        USER_AGENT = UserAgent()
        user_ip, user_agent = USER_AGENT.get_client_ip(
            request), USER_AGENT.get_browser_agent(request)
        #build temporary response to be handel but latter it needs to be web service call
        res = self.requestForNewToken(app_code, mode, pid, rid, _email,
                                      _alt_email, user_ip, user_agent)
        # process for the service call and return back with the response
        dev_mode = getattr(settings, "SKIP_WEB_CALL", 'n')
        log.info(
            '[END]- Request Completed for the re-send token email for forgot password.'
        )
        if dev_mode == 'y':
            return self.handelResponse(request, self.webMockData())

        return self.handelResponse(request, res)
    def post(self, request, app_code):
        '''
           In case user has forgot the password or his account has been hacked including email account,
           he will key in the email/email he has access or most recent password in case account has been hacked.
           @param request: HttpRequest for this web flow.
           @param app_code: Appcode From which user is tying to access.
           @return: if all the details input by the user is correct then he will be navigate to the change password
                    screen, else he will be stay back at the same page with the error details.
        '''
        log.info('[START]-Requesting for the forgot password process to be started to navigate to the change password page.');
        destination, _reset_option = request.GET.get('des'), request.POST.get('preoption');
        _recent_pwd, _alt_email = '', '';
        if _reset_option == '1' or _reset_option == 1:
            _email = request.POST.get('uimSignedUpEmail');
        elif _reset_option == '2' or _reset_option == 2:
            _email, _alt_email, _recent_pwd = request.POST.get('uimEmail'), request.POST.get('uimResetEmailAccessTo'), request.POST.get('uimRecentPwd');
        
        # Get user Agent and IP
        USER_AGENT = UserAgent()
        user_ip, user_agent = USER_AGENT.get_client_ip(request), USER_AGENT.get_browser_agent(request);

        # validate the user submitted form
        errors = self.validateForm(_email, _alt_email, _recent_pwd, _reset_option);
        if errors:
            # add Context and return to the page
            log.info('[END]-As the inputs are not valid asking user to re input the details.');
            return self.stayAtSamePage(request , self.buildErrorMap(app_code, destination, _reset_option, errors))
        
        # process for the service call and return back with the response
        dev_mode = getattr(settings, "SKIP_WEB_CALL", 'n');
        if dev_mode == 'y':
            sr_response = self.buildWebMockData();
        else:
            sr_response = self.forgotPassword(user_agent, user_ip, _email, _alt_email, _recent_pwd, _reset_option, destination);
        
        log.info('[END]-Forgot Password request Completed, processing the response received from web call.');
        return self.processResponse(request, sr_response, destination, app_code, _reset_option, _email, _alt_email);