public async Task <InviteResult> UsePermanentInvitationAsync(User user, string link)
        {
            if (await _inviteSvc.TryDecodePermanentInviteLinkAsync(link, out var guid))
            {
                // org exists
                var orgResult = await _orgRepo.GetByIdAsync(guid);

                if (orgResult.IsSome())
                {
                    return(await GrantAccessAsync(user, orgResult.Unwrap()));
                }
            }
            return(InviteResult.LinkInvalid());
        }
        private async Task <InviteResult> GrantAccessAsync(User user, Organization org)
        {
            var record = await _userOrgRepo.GetByIdsAsync(user.Id, org.Id);

            // Check existing record to see its status if one exists
            if (record.IsSome())
            {
                return(InviteResult.FromExistingAccess(record.Unwrap(), org.Title));
            }

            // Save new record representing User's access to Organization, assign default role
            var accessGrant = new UserOrganization(user.Id, org.Id);

            _userOrgRepo.Add(accessGrant);
            AddDefaultRoleToUserAsync(user.Id, org.Id);
            await _userOrgRepo.UnitOfWork.Commit();

            return(org.RequiresConfirmation
                ? InviteResult.RequiresConfirmation(org.Title)
                : InviteResult.ImmediateSuccess(org.Title));
        }