Exemple #1
0
    def post(self):
        """
        Logging in to the system
        """
        data, status = validate(request.json, 'login')
        if status is False:
            raise BadRequest(json.dumps(data))

        auth = AuthBusiness.login(data['username'], data['password'])
        if not auth:
            raise InternalServerError('Error logging!')

        return auth
Exemple #2
0
    def get(self):
        """
        Generate token to client application
        """
        service = request.args['service']
        scope = request.args.get('scope')

        if request.authorization:
            username = request.authorization.get('username')
            password = request.authorization.get('password')
            user_id = AuthBusiness.login(username, password)['user_id']
        else:
            user_id, _, _ = get_userinfo_by_token()

        auth_client = AuthBusiness.token(user_id, service, scope)
        return auth_client