Пример #1
0
    def Login(self, request, context):
        if not request.username:
            raise XOSNotAuthenticated("No username")

        u=django_authenticate(username=request.username, password=request.password)
        if not u:
            raise XOSNotAuthenticated("Failed to authenticate user %s" % request.username)

        session = SessionStore()
        auth = {"username": request.username, "password": request.password}
        session["auth"] = auth
        session['_auth_user_id'] = u.pk
        session['_auth_user_backend'] = u.backend
        session.save()

        response = utility_pb2.LoginResponse()
        response.sessionid = session.session_key

        return response
Пример #2
0
    def Login(self, request, context):
        if not request.username:
            raise XOSNotAuthenticated("No username")

        u = django_authenticate(username=request.username,
                                password=request.password)
        if not u:
            raise XOSNotAuthenticated("Failed to authenticate user %s" %
                                      request.username)

        session = SessionStore()
        auth = {"username": request.username, "password": request.password}
        session["auth"] = auth
        session["_auth_user_id"] = u.pk
        session["_auth_user_backend"] = u.backend
        session.save()

        response = utility_pb2.LoginResponse()
        response.sessionid = session.session_key

        REQUEST_COUNT.labels("xos-core", "Utilities", "Login",
                             grpc.StatusCode.OK).inc()
        return response