def authenticate_user(self):       
     global AUTHENTICATED
     
     # we should check to see if we are already authenticated before blindly doing it again
     if (AUTHENTICATED == False ):
         obj = Authentication(self._vipr_info['hostname'], int(self._vipr_info['port']))
         cookiedir = '/tmp/vipr_cookie_dir'
         cookiefile = 'cookie-' + self._vipr_info['username'] + '-' + str(os.getpid())
         obj.authenticate_user(self._vipr_info['username'], self._vipr_info['password'], cookiedir, cookiefile)
         AUTHENTICATED = True
 def authenticate_user(self):
     global AUTHENTICATED
     from authentication import Authentication
     # we should check to see if we are already authenticated before blindly
     # doing it again
     if (AUTHENTICATED is False):
         obj = Authentication(self.configuration.vipr_hostname,
                              self.configuration.vipr_port)
         # cookiedir = os.getcwd()
         cookiedir = self.configuration.vipr_cookiedir
         obj.authenticate_user(self.configuration.vipr_username,
                               self.configuration.vipr_password, cookiedir,
                               None)
         AUTHENTICATED = True
Ejemplo n.º 3
0
    def display_login(self):
        cls()
        print("""
        =================================
        | 1. Login As a Buyer           |
        | 2. Login As a Vendor          |
        | 3. Go back                    |
        ================================= \n\n
        """)
        i = Validation.get_int_input(input(), 3)
        if i == 3:
            self.display_store()
        print("Enter Username Or Email")
        username = input()
        print("Enter Password")
        password = input()
        acc_type = "buyer" if i == 1 else "seller"
        while not Authentication.authenticate_user(username, password,
                                                   acc_type):
            print("Invalid Credentials")
            inp = input("Enter 0 to go back or 1 to try again ")
            if inp == "0":
                self.display_login()
                return
            print("Enter Username or Contact info (email/phone)")
            username = input()
            print("Enter Password")
            password = input()

        self.logged_in_menu()
        return
Ejemplo n.º 4
0
    def post(self):
        if 'user' in session:
            return '', 400

        args = parser.parse_args()

        credentials = Authentication.get_credentials(args['Authorization'])
        is_authenticated = Authentication.authenticate_user(credentials)

        if is_authenticated:
            session['user'] = credentials['username']

            return '', 200
        else:
            return '', 401