<commit_before>package request

import (
	"context"
	"github.com/ory/fosite"
)

/* These functions provide a concrete implementation of fosite.AuthorizeCodeGrantStorage */

func (m *MongoManager) PersistAuthorizeCodeGrantSession(ctx context.Context, authorizeCode, accessSignature, refreshSignature string, request fosite.Requester) error {
	if err := m.DeleteAuthorizeCodeSession(ctx, authorizeCode); err != nil {
		return err
	} else if err := m.CreateAccessTokenSession(ctx, accessSignature, request); err != nil {
		return err
	}

	if refreshSignature == "" {
		return nil
	}

	if err := m.CreateRefreshTokenSession(ctx, refreshSignature, request); err != nil {
		return err
	}

	return nil
}<commit_msg>:speech_balloon: request: Add comment to PersistAuthorizeCodeGrantSession<commit_after>package request

import (
	"context"
	"github.com/ory/fosite"
)

/* These functions provide a concrete implementation of fosite.AuthorizeCodeGrantStorage */

// PersistAuthorizeCodeGrantSession creates an Authorise Code Grant session in mongo
func (m *MongoManager) PersistAuthorizeCodeGrantSession(ctx context.Context, authorizeCode, accessSignature, refreshSignature string, request fosite.Requester) error {
	if err := m.DeleteAuthorizeCodeSession(ctx, authorizeCode); err != nil {
		return err
	} else if err := m.CreateAccessTokenSession(ctx, accessSignature, request); err != nil {
		return err
	}

	if refreshSignature == "" {
		return nil
	}

	if err := m.CreateRefreshTokenSession(ctx, refreshSignature, request); err != nil {
		return err
	}

	return nil
}
{'fraction_non_alphanumeric': 0.09417040358744394, 'fraction_numerical': 0.0, 'mean_word_length': 5.349593495934959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2555980', 'n_tokens_mistral': 469, 'n_tokens_neox': 442, 'n_words': 130}