Exemplo n.º 1
0
    def post(self):
        self.set_header('Content-Type', 'application/json')
        username = self.arguments.get("username", None)
        password = self.arguments.get("password", None)
        uri = self.arguments.get("uri", None)
        result = {}

        if uri:
            if self.get_current_user():
                self._response_authorized()
            else:
                self._response_unauthorized()

        elif username and password:
            username = username.encode('utf-8')
            password = password.encode('utf-8')
            authenticated = Hierarchy.authenticate_account(username, password)

            if authenticated:
                self.set_secure_cookie("user", username, secure=True)
                self._response_authorized()
            else:
                self._response_unauthorized()

        else:
            if not username:
                result['username'] = ['Username is required.']
            if not password:
                result['password'] = ['Password is required.']
            self.set_status(400)
            self.write(json.dumps(result))
Exemplo n.º 2
0
    def post(self):
        self.set_header('Content-Type', 'application/json')
        username = self.arguments.get("username", None)
        password = self.arguments.get("password", None)
        uri = self.arguments.get("uri", None)
        result = {}

        if uri:
            if self.get_current_user():
                self._response_authorized()
            else:
                self._response_unauthorized()

        elif username and password:
            username = username.encode('utf-8')
            password = password.encode('utf-8')
            authenticated = Hierarchy.authenticate_account(username, password)

            if authenticated:
                self.set_secure_cookie("user", username, secure=True)
                self._response_authorized()
            else:
                self._response_unauthorized()

        else:
            if not username:
                result['username'] = ['Username is required.']
            if not password:
                result['password'] = ['Password is required.']
            self.set_status(400)
            self.write(json.dumps(result))
Exemplo n.º 3
0
    def post(self):

        self.set_header('Content-Type', 'application/json')
        parameters = dict()

        username = self.get_current_user()
        password = self.get_argument('password', None)

        parameters['customer_context'] = self.get_argument('customer_context', None)

        parameters['password'] = self.get_argument('new_password', None)
        if parameters['password']:
            complexity_passed, complexity = check_password(parameters['password'])
            if not complexity_passed:
                result = {}
                result['pass'] = False
                result['message'] = 'Password must be 8 characters in length and contain lower and upper case characters: Strength = %s' % complexity,
                self.write(json.dumps(result, indent=4))
                return
            if password:

                if not Hierarchy.authenticate_account(username, password):

                    result = {}
                    result['pass'] = False
                    result['message'] = 'Incorrect username or password.'

                    self.write(json.dumps(result, indent=4))
                    return
            else:

                result = {}
                result['pass'] = False
                result['message'] = 'Current password not provided.'

                self.write(json.dumps(result, indent=4))
                return

        parameters['username'] = username

        parameters['fullname'] = self.get_argument('fullname', None)
        parameters['email'] = self.get_argument('email', None)

        parameters['current_customer_id'] = self.get_argument(
            'current_customer_id', None)

        parameters['customer_ids'] = None

        parameters['default_customer_id'] = self.get_argument(
            'default_customer_id', None
        )

        parameters['group_names'] = self.get_arguments('group_name', None)
        parameters['group_ids'] = self.get_arguments('group_id', None)

        result = api.User.edit(**parameters)

        self.write(json.dumps(result, indent=4))
Exemplo n.º 4
0
    def post(self):

        username = self.arguments.get("name", None)
        password = self.arguments.get("password", None)
        username = username.encode('utf-8')
        password = password.encode('utf-8')

        if username and password:

            authenticated = Hierarchy.authenticate_account(username, password)

            if authenticated:
                self.set_secure_cookie("user", username)
                return
            else:
                self.set_status(403)
                self.write("Invalid username and/or password .")
        else:

            self.set_status(403)
            self.write("Invalid username and/or password .")
Exemplo n.º 5
0
    def post(self):

        username = self.arguments.get("name", None)
        password = self.arguments.get("password", None)
        username = username.encode('utf-8')
        password = password.encode('utf-8')

        if username and password:

            authenticated = Hierarchy.authenticate_account(username, password)

            if authenticated:
                self.set_secure_cookie("user", username)
                return
            else:
                self.set_status(403)
                self.write("Invalid username and/or password .")
        else:

            self.set_status(403)
            self.write("Invalid username and/or password .")