Use REST API for confirm endpoint
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -4,12 +4,9 @@ import { Helmet } from "react-helmet-async";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
import { Link } from "react-router";
|
import { Link } from "react-router";
|
||||||
import { useMutation } from "react-relay";
|
|
||||||
import { graphql } from "relay-runtime";
|
|
||||||
import { PayloadError } from "relay-runtime";
|
|
||||||
import { ConfirmInvitationPageMutation } from "./__generated__/ConfirmInvitationPageMutation.graphql";
|
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { buildEndpoint } from "@/utils";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -19,14 +16,6 @@ import {
|
|||||||
CardTitle,
|
CardTitle,
|
||||||
} from "@/components/ui/card";
|
} from "@/components/ui/card";
|
||||||
|
|
||||||
const ConfirmInvitationMutation = graphql`
|
|
||||||
mutation ConfirmInvitationPageMutation($input: ConfirmInvitationInput!) {
|
|
||||||
confirmInvitation(input: $input) {
|
|
||||||
success
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default function ConfirmInvitationPage() {
|
export default function ConfirmInvitationPage() {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isConfirmed, setIsConfirmed] = useState(false);
|
const [isConfirmed, setIsConfirmed] = useState(false);
|
||||||
@@ -37,9 +26,6 @@ export default function ConfirmInvitationPage() {
|
|||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const [commitMutation] = useMutation<ConfirmInvitationPageMutation>(
|
|
||||||
ConfirmInvitationMutation
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Extract token from URL and prefill the form
|
// Extract token from URL and prefill the form
|
||||||
@@ -81,34 +67,30 @@ export default function ConfirmInvitationPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
commitMutation({
|
const response = await fetch(
|
||||||
variables: {
|
buildEndpoint("/api/console/v1/auth/invitation"),
|
||||||
input: {
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
token: token.trim(),
|
token: token.trim(),
|
||||||
password: password,
|
password: password,
|
||||||
},
|
}),
|
||||||
},
|
}
|
||||||
onCompleted: (response, errors: PayloadError[] | null) => {
|
);
|
||||||
if (errors) {
|
|
||||||
throw new Error(
|
|
||||||
errors[0]?.message || "Failed to confirm invitation"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsConfirmed(true);
|
const data = await response.json();
|
||||||
toast({
|
|
||||||
title: "Success",
|
|
||||||
description: "Your invitation has been confirmed successfully",
|
|
||||||
});
|
|
||||||
|
|
||||||
setIsLoading(false);
|
if (!response.ok) {
|
||||||
},
|
throw new Error(data.message || "Failed to confirm invitation");
|
||||||
onError: (err) => {
|
}
|
||||||
setError(
|
|
||||||
err.message || "Failed to confirm invitation. Please try again."
|
setIsConfirmed(true);
|
||||||
);
|
toast({
|
||||||
setIsLoading(false);
|
title: "Success",
|
||||||
},
|
description: "Your invitation has been confirmed successfully",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(
|
setError(
|
||||||
@@ -116,6 +98,7 @@ export default function ConfirmInvitationPage() {
|
|||||||
? error.message
|
? error.message
|
||||||
: "Failed to confirm invitation. Please try again."
|
: "Failed to confirm invitation. Please try again."
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
/**
|
|
||||||
* @generated SignedSource<<8326ebf0af891dd062245db55f40abba>>
|
|
||||||
* @lightSyntaxTransform
|
|
||||||
* @nogrep
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
// @ts-nocheck
|
|
||||||
|
|
||||||
import { ConcreteRequest } from 'relay-runtime';
|
|
||||||
export type ConfirmInvitationInput = {
|
|
||||||
password: string;
|
|
||||||
token: string;
|
|
||||||
};
|
|
||||||
export type ConfirmInvitationPageMutation$variables = {
|
|
||||||
input: ConfirmInvitationInput;
|
|
||||||
};
|
|
||||||
export type ConfirmInvitationPageMutation$data = {
|
|
||||||
readonly confirmInvitation: {
|
|
||||||
readonly success: boolean;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
export type ConfirmInvitationPageMutation = {
|
|
||||||
response: ConfirmInvitationPageMutation$data;
|
|
||||||
variables: ConfirmInvitationPageMutation$variables;
|
|
||||||
};
|
|
||||||
|
|
||||||
const node: ConcreteRequest = (function(){
|
|
||||||
var v0 = [
|
|
||||||
{
|
|
||||||
"defaultValue": null,
|
|
||||||
"kind": "LocalArgument",
|
|
||||||
"name": "input"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
v1 = [
|
|
||||||
{
|
|
||||||
"alias": null,
|
|
||||||
"args": [
|
|
||||||
{
|
|
||||||
"kind": "Variable",
|
|
||||||
"name": "input",
|
|
||||||
"variableName": "input"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"concreteType": "ConfirmInvitationPayload",
|
|
||||||
"kind": "LinkedField",
|
|
||||||
"name": "confirmInvitation",
|
|
||||||
"plural": false,
|
|
||||||
"selections": [
|
|
||||||
{
|
|
||||||
"alias": null,
|
|
||||||
"args": null,
|
|
||||||
"kind": "ScalarField",
|
|
||||||
"name": "success",
|
|
||||||
"storageKey": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"storageKey": null
|
|
||||||
}
|
|
||||||
];
|
|
||||||
return {
|
|
||||||
"fragment": {
|
|
||||||
"argumentDefinitions": (v0/*: any*/),
|
|
||||||
"kind": "Fragment",
|
|
||||||
"metadata": null,
|
|
||||||
"name": "ConfirmInvitationPageMutation",
|
|
||||||
"selections": (v1/*: any*/),
|
|
||||||
"type": "Mutation",
|
|
||||||
"abstractKey": null
|
|
||||||
},
|
|
||||||
"kind": "Request",
|
|
||||||
"operation": {
|
|
||||||
"argumentDefinitions": (v0/*: any*/),
|
|
||||||
"kind": "Operation",
|
|
||||||
"name": "ConfirmInvitationPageMutation",
|
|
||||||
"selections": (v1/*: any*/)
|
|
||||||
},
|
|
||||||
"params": {
|
|
||||||
"cacheID": "b274132385a2cb59047b47de69712aa8",
|
|
||||||
"id": null,
|
|
||||||
"metadata": {},
|
|
||||||
"name": "ConfirmInvitationPageMutation",
|
|
||||||
"operationKind": "mutation",
|
|
||||||
"text": "mutation ConfirmInvitationPageMutation(\n $input: ConfirmInvitationInput!\n) {\n confirmInvitation(input: $input) {\n success\n }\n}\n"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
(node as any).hash = "f1f013a448277ebffb14e954b2c1797c";
|
|
||||||
|
|
||||||
export default node;
|
|
||||||
52
pkg/server/api/console/v1/invitation_confirmation_handler.go
Normal file
52
pkg/server/api/console/v1/invitation_confirmation_handler.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package console_v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/getprobo/probo/pkg/usrmgr"
|
||||||
|
"go.gearno.de/kit/httpserver"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
InvitationConfirmationRequest struct {
|
||||||
|
Token string `json:"token"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
}
|
||||||
|
|
||||||
|
InvitationConfirmationResponse struct {
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func InvitationConfirmationHandler(usrmgrSvc *usrmgr.Service, authCfg AuthConfig) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req InvitationConfirmationRequest
|
||||||
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
|
httpserver.RenderError(w, http.StatusBadRequest, fmt.Errorf("cannot decode body: %w", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err := usrmgrSvc.ConfirmInvitation(r.Context(), req.Token, req.Password)
|
||||||
|
if err != nil {
|
||||||
|
httpserver.RenderError(w, http.StatusInternalServerError, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
httpserver.RenderJSON(w, http.StatusOK, InvitationConfirmationResponse{})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,6 +77,7 @@ func NewMux(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg AuthConf
|
|||||||
r.Post("/auth/register", SignUpHandler(usrmgrSvc, authCfg))
|
r.Post("/auth/register", SignUpHandler(usrmgrSvc, authCfg))
|
||||||
r.Post("/auth/login", SignInHandler(usrmgrSvc, authCfg))
|
r.Post("/auth/login", SignInHandler(usrmgrSvc, authCfg))
|
||||||
r.Delete("/auth/logout", SignOutHandler(usrmgrSvc, authCfg))
|
r.Delete("/auth/logout", SignOutHandler(usrmgrSvc, authCfg))
|
||||||
|
r.Post("/auth/invitation", InvitationConfirmationHandler(usrmgrSvc, authCfg))
|
||||||
|
|
||||||
r.Get("/", playground.Handler("GraphQL", "/api/console/v1/query"))
|
r.Get("/", playground.Handler("GraphQL", "/api/console/v1/query"))
|
||||||
r.Post("/query", graphqlHandler(proboSvc, usrmgrSvc, authCfg))
|
r.Post("/query", graphqlHandler(proboSvc, usrmgrSvc, authCfg))
|
||||||
@@ -105,10 +106,6 @@ func graphqlHandler(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg
|
|||||||
srv.Use(extension.Introspection{})
|
srv.Use(extension.Introspection{})
|
||||||
|
|
||||||
srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
|
srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
|
||||||
if op := graphql.GetOperationContext(ctx); op.OperationName == "IntrospectionQuery" {
|
|
||||||
return next(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
user := UserFromContext(ctx)
|
user := UserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
|
|||||||
@@ -387,7 +387,6 @@ type Mutation {
|
|||||||
|
|
||||||
confirmEmail(input: ConfirmEmailInput!): ConfirmEmailPayload!
|
confirmEmail(input: ConfirmEmailInput!): ConfirmEmailPayload!
|
||||||
inviteUser(input: InviteUserInput!): InviteUserPayload!
|
inviteUser(input: InviteUserInput!): InviteUserPayload!
|
||||||
confirmInvitation(input: ConfirmInvitationInput!): ConfirmInvitationPayload!
|
|
||||||
removeUser(input: RemoveUserInput!): RemoveUserPayload!
|
removeUser(input: RemoveUserInput!): RemoveUserPayload!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,15 +725,6 @@ type InviteUserPayload {
|
|||||||
success: Boolean!
|
success: Boolean!
|
||||||
}
|
}
|
||||||
|
|
||||||
input ConfirmInvitationInput {
|
|
||||||
token: String!
|
|
||||||
password: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConfirmInvitationPayload {
|
|
||||||
success: Boolean!
|
|
||||||
}
|
|
||||||
|
|
||||||
input RemoveUserInput {
|
input RemoveUserInput {
|
||||||
organizationId: ID!
|
organizationId: ID!
|
||||||
userId: ID!
|
userId: ID!
|
||||||
|
|||||||
@@ -65,10 +65,6 @@ type ComplexityRoot struct {
|
|||||||
Success func(childComplexity int) int
|
Success func(childComplexity int) int
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmInvitationPayload struct {
|
|
||||||
Success func(childComplexity int) int
|
|
||||||
}
|
|
||||||
|
|
||||||
Control struct {
|
Control struct {
|
||||||
Category func(childComplexity int) int
|
Category func(childComplexity int) int
|
||||||
CreatedAt func(childComplexity int) int
|
CreatedAt func(childComplexity int) int
|
||||||
@@ -196,7 +192,6 @@ type ComplexityRoot struct {
|
|||||||
Mutation struct {
|
Mutation struct {
|
||||||
AssignTask func(childComplexity int, input types.AssignTaskInput) int
|
AssignTask func(childComplexity int, input types.AssignTaskInput) int
|
||||||
ConfirmEmail func(childComplexity int, input types.ConfirmEmailInput) int
|
ConfirmEmail func(childComplexity int, input types.ConfirmEmailInput) int
|
||||||
ConfirmInvitation func(childComplexity int, input types.ConfirmInvitationInput) int
|
|
||||||
CreateControl func(childComplexity int, input types.CreateControlInput) int
|
CreateControl func(childComplexity int, input types.CreateControlInput) int
|
||||||
CreateFramework func(childComplexity int, input types.CreateFrameworkInput) int
|
CreateFramework func(childComplexity int, input types.CreateFrameworkInput) int
|
||||||
CreateOrganization func(childComplexity int, input types.CreateOrganizationInput) int
|
CreateOrganization func(childComplexity int, input types.CreateOrganizationInput) int
|
||||||
@@ -457,7 +452,6 @@ type MutationResolver interface {
|
|||||||
DeletePolicy(ctx context.Context, input types.DeletePolicyInput) (*types.DeletePolicyPayload, error)
|
DeletePolicy(ctx context.Context, input types.DeletePolicyInput) (*types.DeletePolicyPayload, error)
|
||||||
ConfirmEmail(ctx context.Context, input types.ConfirmEmailInput) (*types.ConfirmEmailPayload, error)
|
ConfirmEmail(ctx context.Context, input types.ConfirmEmailInput) (*types.ConfirmEmailPayload, error)
|
||||||
InviteUser(ctx context.Context, input types.InviteUserInput) (*types.InviteUserPayload, error)
|
InviteUser(ctx context.Context, input types.InviteUserInput) (*types.InviteUserPayload, error)
|
||||||
ConfirmInvitation(ctx context.Context, input types.ConfirmInvitationInput) (*types.ConfirmInvitationPayload, error)
|
|
||||||
RemoveUser(ctx context.Context, input types.RemoveUserInput) (*types.RemoveUserPayload, error)
|
RemoveUser(ctx context.Context, input types.RemoveUserInput) (*types.RemoveUserPayload, error)
|
||||||
}
|
}
|
||||||
type OrganizationResolver interface {
|
type OrganizationResolver interface {
|
||||||
@@ -516,13 +510,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||||||
|
|
||||||
return e.complexity.ConfirmEmailPayload.Success(childComplexity), true
|
return e.complexity.ConfirmEmailPayload.Success(childComplexity), true
|
||||||
|
|
||||||
case "ConfirmInvitationPayload.success":
|
|
||||||
if e.complexity.ConfirmInvitationPayload.Success == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.complexity.ConfirmInvitationPayload.Success(childComplexity), true
|
|
||||||
|
|
||||||
case "Control.category":
|
case "Control.category":
|
||||||
if e.complexity.Control.Category == nil {
|
if e.complexity.Control.Category == nil {
|
||||||
break
|
break
|
||||||
@@ -921,18 +908,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||||||
|
|
||||||
return e.complexity.Mutation.ConfirmEmail(childComplexity, args["input"].(types.ConfirmEmailInput)), true
|
return e.complexity.Mutation.ConfirmEmail(childComplexity, args["input"].(types.ConfirmEmailInput)), true
|
||||||
|
|
||||||
case "Mutation.confirmInvitation":
|
|
||||||
if e.complexity.Mutation.ConfirmInvitation == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
args, err := ec.field_Mutation_confirmInvitation_args(context.TODO(), rawArgs)
|
|
||||||
if err != nil {
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.complexity.Mutation.ConfirmInvitation(childComplexity, args["input"].(types.ConfirmInvitationInput)), true
|
|
||||||
|
|
||||||
case "Mutation.createControl":
|
case "Mutation.createControl":
|
||||||
if e.complexity.Mutation.CreateControl == nil {
|
if e.complexity.Mutation.CreateControl == nil {
|
||||||
break
|
break
|
||||||
@@ -1983,7 +1958,6 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
|
|||||||
inputUnmarshalMap := graphql.BuildUnmarshalerMap(
|
inputUnmarshalMap := graphql.BuildUnmarshalerMap(
|
||||||
ec.unmarshalInputAssignTaskInput,
|
ec.unmarshalInputAssignTaskInput,
|
||||||
ec.unmarshalInputConfirmEmailInput,
|
ec.unmarshalInputConfirmEmailInput,
|
||||||
ec.unmarshalInputConfirmInvitationInput,
|
|
||||||
ec.unmarshalInputCreateControlInput,
|
ec.unmarshalInputCreateControlInput,
|
||||||
ec.unmarshalInputCreateFrameworkInput,
|
ec.unmarshalInputCreateFrameworkInput,
|
||||||
ec.unmarshalInputCreateOrganizationInput,
|
ec.unmarshalInputCreateOrganizationInput,
|
||||||
@@ -2495,7 +2469,6 @@ type Mutation {
|
|||||||
|
|
||||||
confirmEmail(input: ConfirmEmailInput!): ConfirmEmailPayload!
|
confirmEmail(input: ConfirmEmailInput!): ConfirmEmailPayload!
|
||||||
inviteUser(input: InviteUserInput!): InviteUserPayload!
|
inviteUser(input: InviteUserInput!): InviteUserPayload!
|
||||||
confirmInvitation(input: ConfirmInvitationInput!): ConfirmInvitationPayload!
|
|
||||||
removeUser(input: RemoveUserInput!): RemoveUserPayload!
|
removeUser(input: RemoveUserInput!): RemoveUserPayload!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2834,15 +2807,6 @@ type InviteUserPayload {
|
|||||||
success: Boolean!
|
success: Boolean!
|
||||||
}
|
}
|
||||||
|
|
||||||
input ConfirmInvitationInput {
|
|
||||||
token: String!
|
|
||||||
password: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConfirmInvitationPayload {
|
|
||||||
success: Boolean!
|
|
||||||
}
|
|
||||||
|
|
||||||
input RemoveUserInput {
|
input RemoveUserInput {
|
||||||
organizationId: ID!
|
organizationId: ID!
|
||||||
userId: ID!
|
userId: ID!
|
||||||
@@ -3059,29 +3023,6 @@ func (ec *executionContext) field_Mutation_confirmEmail_argsInput(
|
|||||||
return zeroVal, nil
|
return zeroVal, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) field_Mutation_confirmInvitation_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
|
||||||
var err error
|
|
||||||
args := map[string]any{}
|
|
||||||
arg0, err := ec.field_Mutation_confirmInvitation_argsInput(ctx, rawArgs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
args["input"] = arg0
|
|
||||||
return args, nil
|
|
||||||
}
|
|
||||||
func (ec *executionContext) field_Mutation_confirmInvitation_argsInput(
|
|
||||||
ctx context.Context,
|
|
||||||
rawArgs map[string]any,
|
|
||||||
) (types.ConfirmInvitationInput, error) {
|
|
||||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
|
|
||||||
if tmp, ok := rawArgs["input"]; ok {
|
|
||||||
return ec.unmarshalNConfirmInvitationInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐConfirmInvitationInput(ctx, tmp)
|
|
||||||
}
|
|
||||||
|
|
||||||
var zeroVal types.ConfirmInvitationInput
|
|
||||||
return zeroVal, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) field_Mutation_createControl_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
func (ec *executionContext) field_Mutation_createControl_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||||
var err error
|
var err error
|
||||||
args := map[string]any{}
|
args := map[string]any{}
|
||||||
@@ -4440,44 +4381,6 @@ func (ec *executionContext) fieldContext_ConfirmEmailPayload_success(_ context.C
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _ConfirmInvitationPayload_success(ctx context.Context, field graphql.CollectedField, obj *types.ConfirmInvitationPayload) (ret graphql.Marshaler) {
|
|
||||||
fc, err := ec.fieldContext_ConfirmInvitationPayload_success(ctx, field)
|
|
||||||
if err != nil {
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
|
||||||
ctx = rctx // use context from middleware stack in children
|
|
||||||
return obj.Success, nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
ec.Error(ctx, err)
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
if resTmp == nil {
|
|
||||||
if !graphql.HasFieldError(ctx, fc) {
|
|
||||||
ec.Errorf(ctx, "must not be null")
|
|
||||||
}
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
res := resTmp.(bool)
|
|
||||||
fc.Result = res
|
|
||||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) fieldContext_ConfirmInvitationPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
|
||||||
fc = &graphql.FieldContext{
|
|
||||||
Object: "ConfirmInvitationPayload",
|
|
||||||
Field: field,
|
|
||||||
IsMethod: false,
|
|
||||||
IsResolver: false,
|
|
||||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
|
||||||
return nil, errors.New("field of type Boolean does not have child fields")
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return fc, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) _Control_id(ctx context.Context, field graphql.CollectedField, obj *types.Control) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Control_id(ctx context.Context, field graphql.CollectedField, obj *types.Control) (ret graphql.Marshaler) {
|
||||||
fc, err := ec.fieldContext_Control_id(ctx, field)
|
fc, err := ec.fieldContext_Control_id(ctx, field)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -7850,53 +7753,6 @@ func (ec *executionContext) fieldContext_Mutation_inviteUser(ctx context.Context
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Mutation_confirmInvitation(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
|
||||||
fc, err := ec.fieldContext_Mutation_confirmInvitation(ctx, field)
|
|
||||||
if err != nil {
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
|
||||||
ctx = rctx // use context from middleware stack in children
|
|
||||||
return ec.resolvers.Mutation().ConfirmInvitation(rctx, fc.Args["input"].(types.ConfirmInvitationInput))
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
ec.Error(ctx, err)
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
if resTmp == nil {
|
|
||||||
if !graphql.HasFieldError(ctx, fc) {
|
|
||||||
ec.Errorf(ctx, "must not be null")
|
|
||||||
}
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
res := resTmp.(*types.ConfirmInvitationPayload)
|
|
||||||
fc.Result = res
|
|
||||||
return ec.marshalNConfirmInvitationPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐConfirmInvitationPayload(ctx, field.Selections, res)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) fieldContext_Mutation_confirmInvitation(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
|
||||||
fc = &graphql.FieldContext{
|
|
||||||
Object: "Mutation",
|
|
||||||
Field: field,
|
|
||||||
IsMethod: true,
|
|
||||||
IsResolver: true,
|
|
||||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
|
||||||
switch field.Name {
|
|
||||||
case "success":
|
|
||||||
return ec.fieldContext_ConfirmInvitationPayload_success(ctx, field)
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("no field named %q was found under type ConfirmInvitationPayload", field.Name)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
|
||||||
if fc.Args, err = ec.field_Mutation_confirmInvitation_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
|
||||||
ec.Error(ctx, err)
|
|
||||||
return fc, err
|
|
||||||
}
|
|
||||||
return fc, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) _Mutation_removeUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Mutation_removeUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||||
fc, err := ec.fieldContext_Mutation_removeUser(ctx, field)
|
fc, err := ec.fieldContext_Mutation_removeUser(ctx, field)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -14122,40 +13978,6 @@ func (ec *executionContext) unmarshalInputConfirmEmailInput(ctx context.Context,
|
|||||||
return it, nil
|
return it, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalInputConfirmInvitationInput(ctx context.Context, obj any) (types.ConfirmInvitationInput, error) {
|
|
||||||
var it types.ConfirmInvitationInput
|
|
||||||
asMap := map[string]any{}
|
|
||||||
for k, v := range obj.(map[string]any) {
|
|
||||||
asMap[k] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldsInOrder := [...]string{"token", "password"}
|
|
||||||
for _, k := range fieldsInOrder {
|
|
||||||
v, ok := asMap[k]
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
switch k {
|
|
||||||
case "token":
|
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("token"))
|
|
||||||
data, err := ec.unmarshalNString2string(ctx, v)
|
|
||||||
if err != nil {
|
|
||||||
return it, err
|
|
||||||
}
|
|
||||||
it.Token = data
|
|
||||||
case "password":
|
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password"))
|
|
||||||
data, err := ec.unmarshalNString2string(ctx, v)
|
|
||||||
if err != nil {
|
|
||||||
return it, err
|
|
||||||
}
|
|
||||||
it.Password = data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return it, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalInputCreateControlInput(ctx context.Context, obj any) (types.CreateControlInput, error) {
|
func (ec *executionContext) unmarshalInputCreateControlInput(ctx context.Context, obj any) (types.CreateControlInput, error) {
|
||||||
var it types.CreateControlInput
|
var it types.CreateControlInput
|
||||||
asMap := map[string]any{}
|
asMap := map[string]any{}
|
||||||
@@ -15486,45 +15308,6 @@ func (ec *executionContext) _ConfirmEmailPayload(ctx context.Context, sel ast.Se
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
var confirmInvitationPayloadImplementors = []string{"ConfirmInvitationPayload"}
|
|
||||||
|
|
||||||
func (ec *executionContext) _ConfirmInvitationPayload(ctx context.Context, sel ast.SelectionSet, obj *types.ConfirmInvitationPayload) graphql.Marshaler {
|
|
||||||
fields := graphql.CollectFields(ec.OperationContext, sel, confirmInvitationPayloadImplementors)
|
|
||||||
|
|
||||||
out := graphql.NewFieldSet(fields)
|
|
||||||
deferred := make(map[string]*graphql.FieldSet)
|
|
||||||
for i, field := range fields {
|
|
||||||
switch field.Name {
|
|
||||||
case "__typename":
|
|
||||||
out.Values[i] = graphql.MarshalString("ConfirmInvitationPayload")
|
|
||||||
case "success":
|
|
||||||
out.Values[i] = ec._ConfirmInvitationPayload_success(ctx, field, obj)
|
|
||||||
if out.Values[i] == graphql.Null {
|
|
||||||
out.Invalids++
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
panic("unknown field " + strconv.Quote(field.Name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out.Dispatch(ctx)
|
|
||||||
if out.Invalids > 0 {
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
|
|
||||||
atomic.AddInt32(&ec.deferred, int32(len(deferred)))
|
|
||||||
|
|
||||||
for label, dfs := range deferred {
|
|
||||||
ec.processDeferredGroup(graphql.DeferredGroup{
|
|
||||||
Label: label,
|
|
||||||
Path: graphql.GetPath(ctx),
|
|
||||||
FieldSet: dfs,
|
|
||||||
Context: ctx,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
var controlImplementors = []string{"Control", "Node"}
|
var controlImplementors = []string{"Control", "Node"}
|
||||||
|
|
||||||
func (ec *executionContext) _Control(ctx context.Context, sel ast.SelectionSet, obj *types.Control) graphql.Marshaler {
|
func (ec *executionContext) _Control(ctx context.Context, sel ast.SelectionSet, obj *types.Control) graphql.Marshaler {
|
||||||
@@ -16880,13 +16663,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
|
|||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
out.Invalids++
|
out.Invalids++
|
||||||
}
|
}
|
||||||
case "confirmInvitation":
|
|
||||||
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
|
||||||
return ec._Mutation_confirmInvitation(ctx, field)
|
|
||||||
})
|
|
||||||
if out.Values[i] == graphql.Null {
|
|
||||||
out.Invalids++
|
|
||||||
}
|
|
||||||
case "removeUser":
|
case "removeUser":
|
||||||
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
||||||
return ec._Mutation_removeUser(ctx, field)
|
return ec._Mutation_removeUser(ctx, field)
|
||||||
@@ -19166,25 +18942,6 @@ func (ec *executionContext) marshalNConfirmEmailPayload2ᚖgithubᚗcomᚋgetpro
|
|||||||
return ec._ConfirmEmailPayload(ctx, sel, v)
|
return ec._ConfirmEmailPayload(ctx, sel, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalNConfirmInvitationInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐConfirmInvitationInput(ctx context.Context, v any) (types.ConfirmInvitationInput, error) {
|
|
||||||
res, err := ec.unmarshalInputConfirmInvitationInput(ctx, v)
|
|
||||||
return res, graphql.ErrorOnPath(ctx, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) marshalNConfirmInvitationPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐConfirmInvitationPayload(ctx context.Context, sel ast.SelectionSet, v types.ConfirmInvitationPayload) graphql.Marshaler {
|
|
||||||
return ec._ConfirmInvitationPayload(ctx, sel, &v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) marshalNConfirmInvitationPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐConfirmInvitationPayload(ctx context.Context, sel ast.SelectionSet, v *types.ConfirmInvitationPayload) graphql.Marshaler {
|
|
||||||
if v == nil {
|
|
||||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
|
||||||
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
|
||||||
}
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
return ec._ConfirmInvitationPayload(ctx, sel, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) marshalNControl2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControl(ctx context.Context, sel ast.SelectionSet, v *types.Control) graphql.Marshaler {
|
func (ec *executionContext) marshalNControl2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControl(ctx context.Context, sel ast.SelectionSet, v *types.Control) graphql.Marshaler {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||||
|
|||||||
@@ -33,15 +33,6 @@ type ConfirmEmailPayload struct {
|
|||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfirmInvitationInput struct {
|
|
||||||
Token string `json:"token"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConfirmInvitationPayload struct {
|
|
||||||
Success bool `json:"success"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Control struct {
|
type Control struct {
|
||||||
ID gid.GID `json:"id"`
|
ID gid.GID `json:"id"`
|
||||||
Version int `json:"version"`
|
Version int `json:"version"`
|
||||||
|
|||||||
@@ -533,16 +533,6 @@ func (r *mutationResolver) InviteUser(ctx context.Context, input types.InviteUse
|
|||||||
return nil, fmt.Errorf("organization not found")
|
return nil, fmt.Errorf("organization not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfirmInvitation is the resolver for the confirmInvitation field.
|
|
||||||
func (r *mutationResolver) ConfirmInvitation(ctx context.Context, input types.ConfirmInvitationInput) (*types.ConfirmInvitationPayload, error) {
|
|
||||||
err := r.usrmgrSvc.ConfirmInvitation(ctx, input.Token, input.Password)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &types.ConfirmInvitationPayload{Success: true}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveUser is the resolver for the removeUser field.
|
// RemoveUser is the resolver for the removeUser field.
|
||||||
func (r *mutationResolver) RemoveUser(ctx context.Context, input types.RemoveUserInput) (*types.RemoveUserPayload, error) {
|
func (r *mutationResolver) RemoveUser(ctx context.Context, input types.RemoveUserInput) (*types.RemoveUserPayload, error) {
|
||||||
user := UserFromContext(ctx)
|
user := UserFromContext(ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user