Ejemplo n.º 1
0
        internal async Task <TResult> CreateCredentialMappingAsync <TResult>(Guid credentialMappingId,
                                                                             CredentialValidationMethodTypes method, string subjectId, Guid actorId,
                                                                             Func <TResult> onSuccess,
                                                                             Func <TResult> onAlreadyExists,
                                                                             Func <TResult> onTokenAlreadyInUse)
        {
            var rollback = new RollbackAsync <TResult>();

            var methodName           = Enum.GetName(typeof(CredentialValidationMethodTypes), method);
            var credentialMappingDoc = new Documents.CredentialMappingDocument()
            {
                Method  = methodName,
                Subject = subjectId,
                ActorId = actorId,
            };

            rollback.AddTaskCreate(credentialMappingId, credentialMappingDoc, onAlreadyExists, this.repository);

            var lookupDocument = new Azure.Documents.CredentialMappingLookupDocument()
            {
                CredentialMappingId = credentialMappingId,
                Method  = methodName,
                Subject = subjectId,
            };

            rollback.AddTaskCreate(subjectId, methodName, lookupDocument, onTokenAlreadyInUse, this.repository);

            rollback.AddTaskCreateOrUpdate(actorId,
                                           (Documents.ActorMappingsDocument authDoc) => authDoc.AddInviteId(credentialMappingId),
                                           (authDoc) => authDoc.RemoveInviteId(credentialMappingId),
                                           onAlreadyExists, // This should fail on the action above as well
                                           this.repository);

            return(await rollback.ExecuteAsync(onSuccess));
        }
Ejemplo n.º 2
0
 private static CredentialMapping Convert(Documents.CredentialMappingDocument mappingDoc)
 {
     return(new CredentialMapping
     {
         id = mappingDoc.Id,
         actorId = mappingDoc.ActorId,
         method = mappingDoc.Method.AsEnum <CredentialValidationMethodTypes>(),
         subject = mappingDoc.Subject,
     });
 }
Ejemplo n.º 3
0
 private static CredentialMapping Convert(Documents.CredentialMappingDocument mappingDoc)
 {
     Guid.TryParse(mappingDoc.Subject, out Guid loginId);
     return(new CredentialMapping
     {
         id = mappingDoc.Id,
         actorId = mappingDoc.ActorId,
         method = mappingDoc.Method,
         subject = mappingDoc.Subject,
         loginId = loginId
     });
 }