Wire subscribe-to-updates in compliance portal
Visitors can subscribe after sign-in via the Updates CTA or user menu. Also add trust signOut so Log out works from the menu. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -189,3 +189,24 @@ func (r *mutationResolver) UpdateFullName(ctx context.Context, input types.Updat
|
||||
|
||||
return &types.UpdateFullNamePayload{Success: true}, nil
|
||||
}
|
||||
|
||||
// SignOut is the resolver for the signOut field.
|
||||
func (r *mutationResolver) SignOut(ctx context.Context) (*types.SignOutPayload, error) {
|
||||
session := authn.SessionFromContext(ctx)
|
||||
|
||||
err := r.iam.SessionService.CloseSession(ctx, session.ID)
|
||||
if err != nil {
|
||||
if _, ok := errors.AsType[*iam.ErrSessionNotFound](err); ok {
|
||||
return &types.SignOutPayload{Success: true}, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot close session", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
w := gqlutils.HTTPResponseWriterFromContext(ctx)
|
||||
r.sessionCookie.Clear(w)
|
||||
|
||||
return &types.SignOutPayload{Success: true}, nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ extend type Mutation {
|
||||
@authentication(required: OPTIONAL)
|
||||
updateFullName(input: UpdateFullNameInput!): UpdateFullNamePayload
|
||||
@authentication(required: PRESENT) @sessionOnly
|
||||
signOut: SignOutPayload! @authentication(required: PRESENT) @sessionOnly
|
||||
}
|
||||
|
||||
input SendMagicLinkInput {
|
||||
@@ -31,3 +32,7 @@ input UpdateFullNameInput {
|
||||
type UpdateFullNamePayload {
|
||||
success: Boolean!
|
||||
}
|
||||
|
||||
type SignOutPayload {
|
||||
success: Boolean!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user